[wp-trac] [WordPress Trac] #11987: Incorrect handling of WP_DEBUG_DISPLAY

WordPress Trac wp-trac at lists.automattic.com
Tue Feb 16 13:27:21 UTC 2010


#11987: Incorrect handling of WP_DEBUG_DISPLAY
--------------------------+-------------------------------------------------
 Reporter:  ocean90       |        Owner:          
     Type:  defect (bug)  |       Status:  reopened
 Priority:  normal        |    Milestone:          
Component:  General       |      Version:          
 Severity:  normal        |   Resolution:          
 Keywords:  WP_DEBUG      |  
--------------------------+-------------------------------------------------
Changes (by adam.spiers):

 * cc: adam.spiers (added)
  * status:  closed => reopened
  * resolution:  invalid =>


Comment:

 Hi guys, hope you don't mind if I reopen this:

 Replying to [comment:5 nacin]:
 > If you {{{define('WP_DEBUG_DISPLAY', false);}}}, then the default server
 setting will not be overridden. At no time does WP ever override
 display_errors off. It only forces it on when {{{WP_DEBUG}}} unless
 specified otherwise.

 Can I suggest that it would be more useful if WP *did* allow you to
 override {{{display_errors}}} to off?  After all, the default PHP value is
 1 (on), so on a modern vanilla PHP install, {{{WP_DEBUG_DISPLAY}}} is
 completely ineffective: regardless of whether you leave it undefined or
 set it to true or false, the end result is that errors will get displayed.

 It's worth reviewing the text from the original ticket for this variable
 (#10202):

 > Often enough when users enable WP_DEBUG they still do not get any good
 information because most hosts have display_errors set to Off and some
 times do not have access to the error logs.
 >
 > Enabling display_errors when WP_DEBUG is true would make troubleshooting
 much easier.
 >
 > We can add a constant for disabling display_errors for those people that
 would rather just have the errors sent to the globally defined error log
 file.

 So the original intent was to

  * (a) enable {{{display_errors}}} by default when {{{WP_DEBUG}}} is true,
 but also
  * (b) allow disabling of {{{display_errors}}}.

 The current trunk code only satisfies (a).

 Instead, I propose the following behaviour:

  * undefined and {{{WP_DEBUG}}} false -> don't override server setting of
 {{{display_errors}}}
  * undefined and {{{WP_DEBUG}}} true -> override server setting to 1
  * 0 -> override server setting to 0
  * 1 -> override server setting to 1

 This follows the Principle of Least Surprise, since if a user makes the
 effort to set {{{WP_DEBUG_DISPLAY}}}, they will expect it to have an
 effect.

 In other words:

 {{{
 function wp_debug_mode() {
         ...

         if ( defined( 'WP_DEBUG_DISPLAY' ) ) {
                 ini_set( 'display_errors', WP_DEBUG_DISPLAY );
         }

         if ( WP_DEBUG ) {
                 ...
                 if ( ! defined( 'WP_DEBUG_DISPLAY' ) ) {
                         /* Default to displaying errors as per #10202 */
                         ini_set( 'display_errors', 1 );
                 }
                 ...
         }
         ...
 }
 }}}


 This gives the WP admin full flexibility in their choice of setting for
 {{{display_errors}}} without requiring that they have access to the server
 settings (often they don't).

 Thoughts?

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/11987#comment:7>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list