Make WordPress Core

01/09/2019 08:04:55 PM (6 years ago)

Bootstrap/Load: Introduce fatal error recovery mechanism allowing users to still log in to their admin dashboard.

This changeset introduces a WP_Shutdown_Handler class that detects fatal errors and which extension (plugin or theme) causes them. Such an error is then recorded, and an error message is displayed. Subsequently, in certain protected areas, for example the admin, the broken extension will be paused, ensuring that the website is still usable in the respective area. The major benefit is that this mechanism allows site owners to still log in to their website, to fix the problem by either disabling the extension or solving the bug and then resuming the extension.

Extensions are only paused in certain designated areas. The frontend for example stays unaffected, as it is impossible to know what pausing the extension would cause to be missing, so it might be preferrable to clearly see that the website is temporarily not accessible instead.

The fatal error recovery is especially important in scope of encouraging the switch to a maintained PHP version, as not necessarily every WordPress extension is compatible with all PHP versions. If problems occur now, non-technical site owners that do not have immediate access to the codebase are not locked out of their site and can at least temporarily solve the problem quickly.

Websites that have custom requirements in that regard can implement their own shutdown handler by adding a shutdown-handler.php drop-in that returns the handler instance to use, which must be based on a class that inherits WP_Shutdown_Handler. That handler will then be used in place of the default one.

Websites that would like to modify specifically the error template displayed in the frontend can add a php-error.php drop-in that works similarly to the existing db-error.php drop-in.

Props afragen, bradleyt, flixos90, ocean90, schlessera, SergeyBiryukov, spacedmonkey.
Fixes #44458.

1 edited


  • trunk/src/wp-includes/template-loader.php

    r42343 r44524  
    55 * @package WordPress
    66 */
    7 if ( defined( 'WP_USE_THEMES' ) && WP_USE_THEMES ) {
     7if ( wp_using_themes() ) {
    88    /**
    99     * Fires before determining which template to load.
    47 if ( defined( 'WP_USE_THEMES' ) && WP_USE_THEMES ) :
     47if ( wp_using_themes() ) :
    4848    $template = false;
    4949    if ( is_embed() && $template = get_embed_template() ) :
Note: See TracChangeset for help on using the changeset viewer.