Make WordPress Core

Changeset 53578


Ignore:
Timestamp:
06/26/2022 12:35:28 PM (2 years ago)
Author:
SergeyBiryukov
Message:

Upgrade/Install: Add a conditional to facilitate testing of the Rollbacks feature project.

The Rollback Update Failure feature project creates a temporary backup of plugins and themes before updating. This aims to make the update process more reliable and ensure that if a plugin or theme update fails, the previous version can be safely restored.

If the Rollback Update Failure plugin is installed, WP_Upgrader::install_package() will use the move_dir() function from there for better performance. Instead of copying a directory from one location to another, it uses the rename() PHP function to speed up the process, which is instrumental in creating a temporary backup without a delay. If the renaming failed, it falls back to copy_dir() WP function.

This conditional aims to facilitate broader testing of the feature. It is temporary, until the plugin is merged into core.

Props afragen, pbiron, costdev, davidbaumwald, audrasjb, jrf, SergeyBiryukov.
Fixes #56057. See #51857, #54166.

File:
1 edited

Legend:

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

    r53132 r53578  
    594594
    595595        // Copy new version of item into place.
    596         $result = copy_dir( $source, $remote_destination );
     596        if ( class_exists( 'Rollback_Update_Failure\WP_Upgrader' )
     597            && function_exists( '\Rollback_Update_Failure\move_dir' )
     598        ) {
     599            /*
     600             * If the {@link https://wordpress.org/plugins/rollback-update-failure/ Rollback Update Failure}
     601             * feature plugin is installed, use the move_dir() function from there for better performance.
     602             * Instead of copying a directory from one location to another, it uses the rename() PHP function
     603             * to speed up the process. If the renaming failed, it falls back to copy_dir().
     604             *
     605             * This condition aims to facilitate broader testing of the Rollbacks (temp backups) feature project.
     606             * It is temporary, until the plugin is merged into core.
     607             */
     608            $result = \Rollback_Update_Failure\move_dir( $source, $remote_destination );
     609        } else {
     610            $result = copy_dir( $source, $remote_destination );
     611        }
     612
    597613        if ( is_wp_error( $result ) ) {
    598614            if ( $args['clear_working'] ) {
Note: See TracChangeset for help on using the changeset viewer.