WordPress.org

Make WordPress Core

Opened 5 years ago

Last modified 4 months ago

#31839 new enhancement

Setting error reporting level for wp_debug_mode

Reported by: aifrim Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.1.1
Component: Bootstrap/Load Keywords: dev-feedback
Focuses: Cc:
PR Number:

Description

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:

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 gist of it.

Attachments (1)

load.php.diff (465 bytes) - added by aifrim 5 years ago.
wp-incldues/load.php diff

Download all attachments as: .zip

Change History (3)

@aifrim
5 years ago

wp-incldues/load.php diff

#1 follow-up: @jeremyfelt
5 years ago

  • Keywords dev-feedback added
  • Milestone changed from Awaiting Review to Future Release

Hi @aifrim, thanks for the ticket!

I don't think a WP_DEBUG_LEVEL would hurt, though I wouldn't want to encourage devs to silence messages that should be seen during development. Could removing strict notices be enough?

Related: #24357, where the decision to show E_STRICT in PHP 5.4 was made (accepting that it may be too much).

Also, an old duplicate of introducing some sort of log level constant exists in #14371, where it was decided at the time to let things be.

#2 in reply to: ↑ 1 @aifrim
4 years ago

Replying to jeremyfelt:

Hi @aifrim, thanks for the ticket!

I don't think a WP_DEBUG_LEVEL would hurt, though I wouldn't want to encourage devs to silence messages that should be seen during development. Could removing strict notices be enough?

Related: #24357, where the decision to show E_STRICT in PHP 5.4 was made (accepting that it may be too much).

Also, an old duplicate of introducing some sort of log level constant exists in #14371, where it was decided at the time to let things be.

Hy @jeremyfelt,

First, I am sorry for not replying faster to your response. The notification email must have hit spam. You make valid points by not wanting to encourage developers to silence such messages during development.

I made this ticket in order to get rid of the STRICT messages. I have been working a while on a project and it is still in development. Part of its code requires non strict programming and I have allowed WordPress to auto update because I want to launch it with the last available version of WordPress.

So, how about a WP_DEBUG_NONSTRICT constant that disables E_STRICT warnings?

Note: See TracTickets for help on using tickets.