Make WordPress Core

Ticket #47321: 47321.3.diff

File 47321.3.diff, 3.0 KB (added by garrett-eclipse, 6 years ago)

Refreshed patch to include verbiage supplied by @marybaum

  • src/wp-includes/class-wp-fatal-error-handler.php

     
    4141                                load_default_textdomain();
    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 ) {
    5355                        // Catch exceptions and remain silent.
     
    125127         * If no such drop-in is available, this will call {@see WP_Fatal_Error_Handler::display_default_error_template()}.
    126128         *
    127129         * @since 5.2.0
     130         * @since 5.2.2 The `$handled` parameter was added.
    128131         *
    129          * @param array $error Error information retrieved from `error_get_last()`.
     132         * @param array         $error   Error information retrieved from `error_get_last()`.
     133         * @param bool|WP_Error $handled Whether Recovery Mode handled the fatal error.
    130134         */
    131         protected function display_error_template( $error ) {
     135        protected function display_error_template( $error, $handled ) {
    132136                if ( defined( 'WP_CONTENT_DIR' ) ) {
    133137                        // Load custom PHP error template, if present.
    134138                        $php_error_pluggable = WP_CONTENT_DIR . '/php-error.php';
     
    140144                }
    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
    146150        /**
     
    153157         * be used to modify these parameters.
    154158         *
    155159         * @since 5.2.0
     160         * @since 5.2.2 The `$handled` parameter was added.
    156161         *
    157          * @param array $error Error information retrieved from `error_get_last()`.
     162         * @param array         $error   Error information retrieved from `error_get_last()`.
     163         * @param bool|WP_Error $handled Whether Recovery Mode handled the fatal error.
    158164         */
    159         protected function display_default_error_template( $error ) {
     165        protected function display_default_error_template( $error, $handled ) {
    160166                if ( ! function_exists( '__' ) ) {
    161167                        wp_load_translations_early();
    162168                }
     
    169175                        require_once ABSPATH . WPINC . '/class-wp-error.php';
    170176                }
    171177
    172                 if ( is_protected_endpoint() ) {
     178                if ( true === $handled && wp_is_recovery_mode() ) {
     179                        $message = __( 'You’re in recovery mode, but for some reason we are unable to redirect you. This may mean there are several errors. Please contact your site admin, your developer or the WordPress support forums.' );
     180                } elseif ( is_protected_endpoint() ) {
    173181                        $message = __( 'The site is experiencing technical difficulties. Please check your site admin email inbox for instructions.' );
    174182                } else {
    175183                        $message = __( 'The site is experiencing technical difficulties.' );