Make WordPress Core

Changeset 45114


Ignore:
Timestamp:
04/05/2019 03:19:50 PM (6 years ago)
Author:
flixos90
Message:

Bootstrap/Load: Ensure WP_Fatal_Error_Handler does not conflict with existing mechanisms treating fatal errors.

Prior to this change, resuming or activating a plugin or theme that is still broken would result in a redirect loop if in recovery mode. If outside recovery mode, it would cause the error template to be displayed.

Furthermore this applies to breaking a plugin or theme when editing from the backend.

Props aandrewdixon, azaozz, dhanukanuwan, henrywright, ocean90, ohiosierra, PandelisZ, xkon.
Fixes #46045, #46751.

Location:
trunk/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/plugin.php

    r45085 r45114  
    632632            wp_redirect( add_query_arg( '_error_nonce', wp_create_nonce( 'plugin-activation-error_' . $plugin ), $redirect ) ); // we'll override this later if the plugin can be included without fatal error
    633633        }
     634
    634635        ob_start();
    635636        wp_register_plugin_realpath( WP_PLUGIN_DIR . '/' . $plugin );
    636637        $_wp_plugin_file = $plugin;
     638        define( 'WP_SANDBOX_SCRAPING', true );
    637639        include_once( WP_PLUGIN_DIR . '/' . $plugin );
    638640        $plugin = $_wp_plugin_file; // Avoid stomping of the $plugin variable in a plugin.
     
    21262128 */
    21272129function plugin_sandbox_scrape( $plugin ) {
     2130    define( 'WP_SANDBOX_SCRAPING', true );
    21282131    wp_register_plugin_realpath( WP_PLUGIN_DIR . '/' . $plugin );
    21292132    include( WP_PLUGIN_DIR . '/' . $plugin );
  • trunk/src/wp-admin/includes/theme.php

    r44975 r45114  
    860860            // Load the theme's functions.php to test whether it throws a fatal error.
    861861            ob_start();
     862            define( 'WP_SANDBOX_SCRAPING', true );
    862863            include $functions_path;
    863864            ob_clean();
  • trunk/src/wp-includes/class-wp-fatal-error-handler.php

    r45025 r45114  
    2727     */
    2828    public function handle() {
     29        if ( defined( 'WP_SANDBOX_SCRAPING' ) && WP_SANDBOX_SCRAPING ) {
     30            return;
     31        }
     32
    2933        try {
    3034            // Bail if no error found.
  • trunk/src/wp-includes/load.php

    r45022 r45114  
    14451445        die();
    14461446    }
     1447    define( 'WP_SANDBOX_SCRAPING', true );
    14471448    register_shutdown_function( 'wp_finalize_scraping_edited_file_errors', $key );
    14481449}
Note: See TracChangeset for help on using the changeset viewer.