[wp-trac] [WordPress Trac] #51336: Support php-error.php outside of WP_CONTENT_DIR

WordPress Trac noreply at wordpress.org
Fri Sep 18 04:34:48 UTC 2020


#51336: Support php-error.php outside of WP_CONTENT_DIR
-------------------------+-----------------------------
 Reporter:  brookedot    |      Owner:  (none)
     Type:  enhancement  |     Status:  new
 Priority:  normal       |  Milestone:  Awaiting Review
Component:  Site Health  |    Version:  5.2
 Severity:  normal       |   Keywords:
  Focuses:               |
-------------------------+-----------------------------
 Since 5.2 WordPress has supported a `php-error.php` drop-in which
 overwrites the error template:
 https://make.wordpress.org/core/2019/04/16/fatal-error-recovery-mode-
 in-5-2/

 This is happening in `class-wp-fatal-error-handler.php` on 143
 https://core.trac.wordpress.org/browser/trunk/src/wp-includes/class-wp-
 fatal-error-handler.php#L141



 {{{#!php
 ...
 // Load custom PHP error template, if present.
 $php_error_pluggable = WP_CONTENT_DIR . '/php-error.php';
 ...
 }}}

 In some cases, `WP_CONTENT_DIR` is read-only which means that this file
 cannot be used to customize the message. I'm open to other solutions but
 at the moment, I would like to propose we add an additional constant here
 instead.

 {{{#!php
 if ( defined( 'WP_CONTENT_DIR' ) ) {
         // Load custom PHP error template, if present.
         if ( defined( WP_ERROR_TEMPLATE_DIR ) {
                 $php_error_pluggable_dir = WP_ERROR_TEMPLATE_DIR;
         } else {
                 $php_error_pluggable_dir = WP_CONTENT_DIR;
         }
         $php_error_pluggable = $php_error_pluggable_dir . '/php-
 error.php';
         if ( is_readable( $php_error_pluggable ) ) {
                 require_once $php_error_pluggable;
                 return;
         }
 }
 }}}

 That conditional could probably be simplified too :)

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


More information about the wp-trac mailing list