Make WordPress Core


Ignore:
Timestamp:
03/21/2019 09:52:07 PM (6 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-includes/capabilities.php

    r44717 r44973  
    465465            }
    466466            break;
     467        case 'resume_plugin':
     468            $caps[] = 'resume_plugins';
     469            break;
     470        case 'resume_theme':
     471            $caps[] = 'resume_themes';
     472            break;
    467473        case 'delete_user':
    468474        case 'delete_users':
     
    951957    return $allcaps;
    952958}
     959
     960/**
     961 * Filters the user capabilities to grant the 'resume_plugins' and 'resume_themes' capabilities as necessary.
     962 *
     963 * @since 5.2.0
     964 *
     965 * @param bool[] $allcaps An array of all the user's capabilities.
     966 * @return bool[] Filtered array of the user's capabilities.
     967 */
     968function wp_maybe_grant_resume_extensions_caps( $allcaps ) {
     969    // Even in a multisite, regular administrators should be able to resume plugins.
     970    if ( ! empty( $allcaps['activate_plugins'] ) ) {
     971        $allcaps['resume_plugins'] = true;
     972    }
     973
     974    // Even in a multisite, regular administrators should be able to resume themes.
     975    if ( ! empty( $allcaps['switch_themes'] ) ) {
     976        $allcaps['resume_themes'] = true;
     977    }
     978
     979    return $allcaps;
     980}
Note: See TracChangeset for help on using the changeset viewer.