Make WordPress Core

01/21/2019 08:14:56 PM (5 years ago)

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.

1 edited


  • trunk/src/wp-settings.php

    r44524 r44674  
    1919require( ABSPATH . WPINC . '/load.php' );
    2020require( ABSPATH . WPINC . '/class-wp-paused-extensions-storage.php' );
    21 require( ABSPATH . WPINC . '/class-wp-shutdown-handler.php' );
     21require( ABSPATH . WPINC . '/class-wp-fatal-error-handler.php' );
    2222require( ABSPATH . WPINC . '/error-protection.php' );
    2323require( ABSPATH . WPINC . '/default-constants.php' );
    2424require_once( ABSPATH . WPINC . '/plugin.php' );
    26 // Make sure we register the premature shutdown handler as soon as possible.
    27 wp_register_premature_shutdown_handler();
     26// Make sure we register the shutdown handler for fatal errors as soon as possible.
Note: See TracChangeset for help on using the changeset viewer.