Make WordPress Core

Changeset 46119


Ignore:
Timestamp:
09/15/2019 01:17:24 AM (5 years ago)
Author:
SergeyBiryukov
Message:

Site Health: Show a more specific fatal error message when in Recovery Mode with headers already sent.

Props garrett-eclipse, TimothyBlynJacobs, mukesh27, marybaum, afragen, Clorith, mdwolinski, SergeyBiryukov.
Fixes #47321.

File:
1 edited

Legend:

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

    r45311 r46119  
    4242            }
    4343
     44            $handled = false;
     45
    4446            if ( ! is_multisite() && wp_recovery_mode()->is_initialized() ) {
    45                 wp_recovery_mode()->handle_error( $error );
     47                $handled = wp_recovery_mode()->handle_error( $error );
    4648            }
    4749
    4850            // Display the PHP error template if headers not sent.
    4951            if ( is_admin() || ! headers_sent() ) {
    50                 $this->display_error_template( $error );
     52                $this->display_error_template( $error, $handled );
    5153            }
    5254        } catch ( Exception $e ) {
     
    126128     *
    127129     * @since 5.2.0
    128      *
    129      * @param array $error Error information retrieved from `error_get_last()`.
    130      */
    131     protected function display_error_template( $error ) {
     130     * @since 5.3.0 The `$handled` parameter was added.
     131     *
     132     * @param array         $error   Error information retrieved from `error_get_last()`.
     133     * @param true|WP_Error $handled Whether Recovery Mode handled the fatal error.
     134     */
     135    protected function display_error_template( $error, $handled ) {
    132136        if ( defined( 'WP_CONTENT_DIR' ) ) {
    133137            // Load custom PHP error template, if present.
     
    141145
    142146        // Otherwise, display the default error template.
    143         $this->display_default_error_template( $error );
     147        $this->display_default_error_template( $error, $handled );
    144148    }
    145149
     
    154158     *
    155159     * @since 5.2.0
    156      *
    157      * @param array $error Error information retrieved from `error_get_last()`.
    158      */
    159     protected function display_default_error_template( $error ) {
     160     * @since 5.3.0 The `$handled` parameter was added.
     161     *
     162     * @param array         $error   Error information retrieved from `error_get_last()`.
     163     * @param true|WP_Error $handled Whether Recovery Mode handled the fatal error.
     164     */
     165    protected function display_default_error_template( $error, $handled ) {
    160166        if ( ! function_exists( '__' ) ) {
    161167            wp_load_translations_early();
     
    170176        }
    171177
    172         if ( is_protected_endpoint() ) {
    173             $message = __( 'The site is experiencing technical difficulties. Please check your site admin email inbox for instructions.' );
     178        if ( true === $handled && wp_is_recovery_mode() ) {
     179            $message = __( 'There has been a critical error on your website, putting it in recovery mode. Please check the Themes and Plugins screens for more details. If you just installed or updated a theme or plugin, check the relevant page for that first.' );
     180        } elseif ( is_protected_endpoint() ) {
     181            $message = __( 'There has been a critical error on your website. Please check your site admin email inbox for instructions.' );
    174182        } else {
    175             $message = __( 'The site is experiencing technical difficulties.' );
     183            $message = __( 'There has been a critical error on your website.' );
    176184        }
    177185
Note: See TracChangeset for help on using the changeset viewer.