[wp-trac] [WordPress Trac] #31839: Setting error reporting level for wp_debug_mode

WordPress Trac noreply at wordpress.org
Wed Apr 1 16:25:35 UTC 2015


#31839: Setting error reporting level for wp_debug_mode
----------------------------+-----------------------------
 Reporter:  aifrim          |      Owner:
     Type:  enhancement     |     Status:  new
 Priority:  normal          |  Milestone:  Awaiting Review
Component:  Bootstrap/Load  |    Version:  4.1.1
 Severity:  normal          |   Keywords:
  Focuses:                  |
----------------------------+-----------------------------
 Since PHP 5.4.0 `E_STRICT` errors appear as part of `E_ALL` and headers
 cannot be sent sometimes - stuff that can lead to a whole set of problems.
 For me, they are useless and annoying - but for others they can be useful.

 I just want the possibility to set the `error_reporting` level used in
 `wp_debug_mode()`. I have applied a small patch to `load.php` as shown
 below.

 I have defined a `WP_DEBUG_LEVEL` constant in `wp-config.php` like so:
 `define( 'WP_DEBUG_LEVEL', E_ALL & ~E_STRICT );` because I do not want to
 see the `E_STRICT` warnings.

 Afterwards I modified the `wp_debug_mode` function like so:

 {{{
 #!php
 function wp_debug_mode() {
         if ( WP_DEBUG ) {
                 if( !defined( WP_DEBUG_LEVEL ) )
                     define( 'WP_DEBUG_LEVEL' , E_ALL) ;

                 error_reporting( WP_DEBUG_LEVEL  );

                 if ( WP_DEBUG_DISPLAY )
                         ini_set( 'display_errors', 1 );
                 elseif ( null !== WP_DEBUG_DISPLAY )
                         ini_set( 'display_errors', 0 );

                 if ( WP_DEBUG_LOG ) {
                         ini_set( 'log_errors', 1 );
                         ini_set( 'error_log', WP_CONTENT_DIR .
 '/debug.log' );
                 }
         } else {
                 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 );
         }
         if ( defined( 'XMLRPC_REQUEST' ) )
                 ini_set( 'display_errors', 0 );
 }

 }}}

 Here's the [https://gist.github.com/AlexandruIfrim/8e3626f27344f8f28a87
 gist] of it.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/31839>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list