Debug mode shows Strict Standards

When I set WP_DEBUG to true in wp-config.php, I get to see all the strict standards and deprecated messages.

I’ve set the error_reporting in my php.ini, ini_set() and error_reporting() to E_ERROR | E_WARNING | E_PARSE. But I still get to see the strict standards messages.

Read More

I know the messages can be useful, but they appear in some of the plugins I am using and I am not interested in seeing them. How do I disable them?

Related posts

2 comments

  1. Just don’t set WP_DEBUG to TRUE. The error level is set in wp_debug_mode(), which is called in wp-settings.php before any plugins are loaded. If you leave the default values WordPress will set it to:

    error_reporting( 
        E_CORE_ERROR | 
        E_CORE_WARNING | 
        E_COMPILE_ERROR | 
        E_ERROR | 
        E_WARNING | 
        E_PARSE | 
        E_USER_ERROR | 
        E_USER_WARNING | 
        E_RECOVERABLE_ERROR 
    );
    

    But you should keep strict standard messages on, because in some cases they advance to real errors in later PHP versions, so it is better to fix them early.

  2. To hide strict errors you could use the solution provided by RadGH here: just put the following code in a must use plugin (a single php file under /wp-content/mu-plugins/)

    if (WP_DEBUG && WP_DEBUG_DISPLAY) 
    {
       ini_set('error_reporting', E_ALL & ~E_STRICT & ~E_DEPRECATED);
    }
    

Comments are closed.