Opened 6 years ago
Last modified 6 years ago
#51336 new enhancement
Support php-error.php outside of WP_CONTENT_DIR
| Reported by: | brookedot | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | Awaiting Review |
| Component: | Site Health | Version: | 5.2 |
| Severity: | normal | Keywords: | reporter-feedback |
| Cc: | Focuses: |
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 :)
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
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.