Make WordPress Core


Ignore:
Timestamp:
03/21/2019 09:52:07 PM (4 years ago)
Author:
flixos90
Message:

Bootstrap/Load: Introduce a recovery mode for fixing fatal errors.

Using the new fatal handler introduced in [44962], an email is sent to the admin when a fatal error occurs. This email includes a secret link to enter recovery mode. When clicked, the link will be validated and on success a cookie will be placed on the client, enabling recovery mode for that user. This functionality is executed early before plugins and themes are loaded, in order to be unaffected by potential fatal errors these might be causing.

When in recovery mode, broken plugins and themes will be paused for that client, so that they are able to access the admin backend despite of these errors. They are notified about the broken extensions and the errors caused, and can then decide whether they would like to temporarily deactivate the extension or fix the problem and resume the extension.

A link in the admin bar allows the client to exit recovery mode.

Props timothyblynjacobs, afragen, flixos90, nerrad, miss_jwo, schlessera, spacedmonkey, swissspidy.
Fixes #46130, #44458.

File:
1 edited

Legend:

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

    r44717 r44973  
    390390            break;
    391391
     392        case 'resume':
     393            if ( is_multisite() ) {
     394                return;
     395            }
     396
     397            if ( ! current_user_can( 'resume_plugin', $plugin ) ) {
     398                wp_die( __( 'Sorry, you are not allowed to resume this plugin.' ) );
     399            }
     400
     401            check_admin_referer( 'resume-plugin_' . $plugin );
     402
     403            $result = resume_plugin( $plugin, self_admin_url( "plugins.php?error=resuming&plugin_status=$status&paged=$page&s=$s" ) );
     404
     405            if ( is_wp_error( $result ) ) {
     406                wp_die( $result );
     407            }
     408
     409            wp_redirect( self_admin_url( "plugins.php?resume=true&plugin_status=$status&paged=$page&s=$s" ) );
     410            exit;
     411
    392412        default:
    393413            if ( isset( $_POST['checked'] ) ) {
     
    489509        );
    490510        $errmsg .= ' ' . __( 'If you notice “headers already sent” messages, problems with syndication feeds or other issues, try deactivating or removing this plugin.' );
     511    } elseif ( 'resuming' === $_GET['error'] ) {
     512        $errmsg = __( 'Plugin could not be resumed because it triggered a <strong>fatal error</strong>.' );
    491513    } else {
    492514        $errmsg = __( 'Plugin could not be activated because it triggered a <strong>fatal error</strong>.' );
     
    542564<?php elseif ( 'update-selected' == $action ) : ?>
    543565    <div id="message" class="updated notice is-dismissible"><p><?php _e( 'All selected plugins are up to date.' ); ?></p></div>
     566<?php elseif ( isset( $_GET['resume'] ) ) : ?>
     567    <div id="message" class="updated notice is-dismissible"><p><?php _e( 'Plugin <strong>resumed</strong>.' ); ?></p></div>
    544568<?php endif; ?>
    545569
Note: See TracChangeset for help on using the changeset viewer.