WordPress.org

Make WordPress Core


Ignore:
Timestamp:
01/21/2019 08:14:56 PM (3 years ago)
Author:
flixos90
Message:

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.

File:
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-fatal-error-handler.php

    r44673 r44674  
    11<?php
    22/**
    3  * Error Protection API: WP_Shutdown_Handler class
     3 * Error Protection API: WP_Fatal_Error_Handler class
    44 *
    55 * @package WordPress
     
    88
    99/**
    10  * Core class used as the default shutdown handler.
     10 * Core class used as the default shutdown handler for fatal errors.
    1111 *
    12  * A drop-in 'shutdown-handler.php' can be used to override the instance of this class and use a custom implementation
    13  * for the shutdown handler that WordPress registers. The custom class should extend this class and can override its
    14  * methods individually as necessary. The file must return the instance of the class that should be registered.
     12 * A drop-in 'fatal-error-handler.php' can be used to override the instance of this class and use a custom
     13 * implementation for the fatal error handler that WordPress registers. The custom class should extend this class and
     14 * can override its methods individually as necessary. The file must return the instance of the class that should be
     15 * registered.
    1516 *
    1617 * @since 5.1.0
    1718 */
    18 class WP_Shutdown_Handler {
     19class WP_Fatal_Error_Handler {
    1920
    2021    /**
     
    127128     * `wp-includes/load.php` should be checked for before being called.
    128129     *
    129      * If no such drop-in is available, this will call {@see WP_Shutdown_Handler::display_default_error_template()}.
     130     * If no such drop-in is available, this will call {@see WP_Fatal_Error_Handler::display_default_error_template()}.
    130131     *
    131132     * @since 5.1.0
Note: See TracChangeset for help on using the changeset viewer.