From ffc2d83dea126816083c7fe1ddc28ad021869ed4 Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers Date: Wed, 15 May 2019 18:18:02 +0000 Subject: [PATCH] Bootstrap/Load: Prevent PHP errors when a drop-in triggers fatal error protection. When a drop-in (such as `advanced-cache.php`) contains a PHP error, additional PHP errors are caused when displaying the error protection screen because `load_default_textdomain()` and `WP_Error` are not yet available. Though recovery mode is not supported for `mu-plugins` and drop-ins, fatal error protection is. This change ensures the error screen is displayed when a fatal error is encountered within a drop-in and not a white screen. Props TimothyBlynJacobs, spacedmonkey, daxelrod. Fixes #47265. git-svn-id: https://develop.svn.wordpress.org/trunk@45311 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/class-wp-fatal-error-handler.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/wp-includes/class-wp-fatal-error-handler.php b/src/wp-includes/class-wp-fatal-error-handler.php index 96958d10de..f17011cc33 100644 --- a/src/wp-includes/class-wp-fatal-error-handler.php +++ b/src/wp-includes/class-wp-fatal-error-handler.php @@ -37,7 +37,7 @@ class WP_Fatal_Error_Handler { return; } - if ( ! isset( $GLOBALS['wp_locale'] ) ) { + if ( ! isset( $GLOBALS['wp_locale'] ) && function_exists( 'load_default_textdomain' ) ) { load_default_textdomain(); } @@ -165,6 +165,10 @@ class WP_Fatal_Error_Handler { require_once ABSPATH . WPINC . '/functions.php'; } + if ( ! class_exists( 'WP_Error' ) ) { + require_once ABSPATH . WPINC . '/class-wp-error.php'; + } + if ( is_protected_endpoint() ) { $message = __( 'The site is experiencing technical difficulties. Please check your site admin email inbox for instructions.' ); } else {