Make WordPress Core


Ignore:
Timestamp:
05/10/2024 11:46:51 AM (5 months ago)
Author:
johnbillion
Message:

Upgrade/Install: Automatically roll back to the previous version when an automatic plugin update results in a fatal error on the front end of the site.

This builds on the temporary backup system introduced in 6.3 to allow automatic updates to benefit from fatal error protection. A loopback request is performed to the home page of the site and the plugin is rolled back to its backed up version if a fatal error is observed.

For debugging and observability during beta, this change includes several calls to error_log() during the upgrade and rollback stages. These calls can be removed or placed behind a flag once we're ready for RC1.

Props costdev, johnbillion, mukesh27, afragen, audrasjb, justlevine, kirasong, peterwilsoncc

Fixes #58281

File:
1 edited

Legend:

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

    r57831 r58128  
    419419    if ( ( time() - $upgrading ) >= 10 * MINUTE_IN_SECONDS ) {
    420420        return false;
     421    }
     422
     423    // Don't enable maintenance mode while scraping for fatal errors.
     424    if ( is_int( $upgrading ) && isset( $_REQUEST['wp_scrape_key'], $_REQUEST['wp_scrape_nonce'] ) ) {
     425        $key   = stripslashes( $_REQUEST['wp_scrape_key'] );
     426        $nonce = stripslashes( $_REQUEST['wp_scrape_nonce'] );
     427
     428        if ( md5( $upgrading ) === $key && (int) $nonce === $upgrading ) {
     429            return false;
     430        }
    421431    }
    422432
Note: See TracChangeset for help on using the changeset viewer.