From 2caa621b0d935f700790f3c3f6fe7630b40c2cc9 Mon Sep 17 00:00:00 2001 From: Felix Arntz Date: Mon, 21 Jan 2019 20:14:56 +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. git-svn-id: https://develop.svn.wordpress.org/trunk@44674 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/includes/plugin.php | 16 ++++---- ...r.php => class-wp-fatal-error-handler.php} | 15 +++---- src/wp-includes/error-protection.php | 39 ++++++++++++++++--- src/wp-settings.php | 6 +-- 4 files changed, 53 insertions(+), 23 deletions(-) rename src/wp-includes/{class-wp-shutdown-handler.php => class-wp-fatal-error-handler.php} (89%) diff --git a/src/wp-admin/includes/plugin.php b/src/wp-admin/includes/plugin.php index 419ba1659c..a2a579eacb 100644 --- a/src/wp-admin/includes/plugin.php +++ b/src/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/src/wp-includes/class-wp-shutdown-handler.php b/src/wp-includes/class-wp-fatal-error-handler.php similarity index 89% rename from src/wp-includes/class-wp-shutdown-handler.php rename to src/wp-includes/class-wp-fatal-error-handler.php index 18eee6a2a4..0299b67a48 100644 --- a/src/wp-includes/class-wp-shutdown-handler.php +++ b/src/wp-includes/class-wp-fatal-error-handler.php @@ -1,21 +1,22 @@