Opened 4 years ago
Last modified 4 years ago
#51336 new enhancement
Support php-error.php outside of WP_CONTENT_DIR
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | 5.2 |
Component: | Site Health | Keywords: | reporter-feedback |
Focuses: | Cc: |
Description
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
...
// 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.
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 :)
Change History (3)
Note: See
TracTickets for help on using
tickets.
Hello, and welcome to Trac.
Is there a sane reason to set wp-content to read-only?
It's the location for all drop-ins, not just this one. It also used for uploads (by default) and often for cache. Everything else, but wp-content, set to read-only seems more sane.