From 7daa39eb1d1ed0dab347ee74d4f141abcc7b7f3a Mon Sep 17 00:00:00 2001 From: Felix Arntz Date: Mon, 21 Jan 2019 20:15:50 +0000 Subject: [PATCH] Bootstrap/Load: Change `shutdown handler` naming to final `fatal error handler` and allow disabling the handler entirely via a constant. The `WP_Shutdown_Handler` name plus related function names were premature when originally committed, as there can be multiple shutdown handlers in PHP, and WordPress makes use of that feature. This changeset modifies the name to a more appropriate `WP_Fatal_Error_Handler`, and related to that changes the following names: * The drop-in to override the handler is now called `fatal-error-handler.php`. * The internal function `wp_register_premature_shutdown_handler` is now called `wp_register_fatal_error_handler()`. In addition to these naming changes, a new constant `WP_DISABLE_FATAL_ERROR_HANDLER` is introduced that can be set in `wp-config.php` to entirely disable the fatal error handler. That constant's value is and should be accessed indirectly via a new `wp_is_fatal_error_handler_enabled()` function and is filterable via a new `wp_fatal_error_handler_enabled` hook. Note that disabling the fatal error handler will skip the new functionality entirely, including the potentially used `fatal-error-handler.php` drop-in. The new set of constant, filter and function provide for an easier-to-use mechanism to disable the fatal error handler altogether, rather than requiring developers to implement a drop-in for purely that purpose. Props afragen, flixos90, joyously, knutsp, markjaquith, ocean90, schlessera, spacedmonkey. Fixes #46047. See #44458. Built from https://develop.svn.wordpress.org/trunk@44674 git-svn-id: http://core.svn.wordpress.org/trunk@44505 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/plugin.php | 16 ++++---- ...r.php => class-wp-fatal-error-handler.php} | 15 +++---- wp-includes/error-protection.php | 39 ++++++++++++++++--- wp-includes/version.php | 2 +- wp-settings.php | 6 +-- 5 files changed, 54 insertions(+), 24 deletions(-) rename wp-includes/{class-wp-shutdown-handler.php => class-wp-fatal-error-handler.php} (89%) diff --git a/wp-admin/includes/plugin.php b/wp-admin/includes/plugin.php index 419ba1659c..a2a579eacb 100644 --- a/wp-admin/includes/plugin.php +++ b/wp-admin/includes/plugin.php @@ -468,14 +468,14 @@ function get_dropins() { */ function _get_dropins() { $dropins = array( - 'advanced-cache.php' => array( __( 'Advanced caching plugin.' ), 'WP_CACHE' ), // WP_CACHE - 'db.php' => array( __( 'Custom database class.' ), true ), // auto on load - 'db-error.php' => array( __( 'Custom database error message.' ), true ), // auto on error - 'install.php' => array( __( 'Custom installation script.' ), true ), // auto on installation - 'maintenance.php' => array( __( 'Custom maintenance message.' ), true ), // auto on maintenance - 'object-cache.php' => array( __( 'External object cache.' ), true ), // auto on load - 'php-error.php' => array( __( 'Custom PHP error message.' ), true ), // auto on error - 'shutdown-handler.php' => array( __( 'Custom PHP shutdown handler.' ), true ), // auto on error + 'advanced-cache.php' => array( __( 'Advanced caching plugin.' ), 'WP_CACHE' ), // WP_CACHE + 'db.php' => array( __( 'Custom database class.' ), true ), // auto on load + 'db-error.php' => array( __( 'Custom database error message.' ), true ), // auto on error + 'install.php' => array( __( 'Custom installation script.' ), true ), // auto on installation + 'maintenance.php' => array( __( 'Custom maintenance message.' ), true ), // auto on maintenance + 'object-cache.php' => array( __( 'External object cache.' ), true ), // auto on load + 'php-error.php' => array( __( 'Custom PHP error message.' ), true ), // auto on error + 'fatal-error-handler.php' => array( __( 'Custom PHP fatal error handler.' ), true ), // auto on error ); if ( is_multisite() ) { diff --git a/wp-includes/class-wp-shutdown-handler.php b/wp-includes/class-wp-fatal-error-handler.php similarity index 89% rename from wp-includes/class-wp-shutdown-handler.php rename to wp-includes/class-wp-fatal-error-handler.php index 18eee6a2a4..0299b67a48 100644 --- a/wp-includes/class-wp-shutdown-handler.php +++ b/wp-includes/class-wp-fatal-error-handler.php @@ -1,21 +1,22 @@