Make WordPress Core

Changeset 55055


Ignore:
Timestamp:
01/12/2023 12:17:45 AM (23 months ago)
Author:
SergeyBiryukov
Message:

Upgrade/Install: Revert a temporary conditional for testing the Rollbacks feature project.

The Rollback Update Failure feature project has been split into two plugins for testing:

  • Faster Updates speeds up plugin or theme updates by moving files rather than copying them, thus decreasing the memory usage and reducing the chance of timeouts or running out of disk space during updates.
  • Rollback Update Failure 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.

The current priority of the feature project is to test the new move_dir() function, which offers better performance than copy_dir(). Instead of copying a directory in a recursive manner file by file from one location to another, move_dir() uses the rename() PHP function to speed up the process, which is instrumental in updating large plugins without a delay. If the renaming failed, it falls back to the copy_dir() WP function.

The move_dir() function is self-contained in the Faster Updates plugin and does not require any special hooks in core, so the conditional previously added to WP_Upgrader::install_package() to facilitate testing is no longer needed and can be removed.

Follow-up to [53578], [54484], [54643].

Props afragen, costdev, peterwilsoncc.
See #56057, #57375, #57386.

File:
1 edited

Legend:

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

    r54867 r55055  
    595595
    596596        // Copy new version of item into place.
    597         if ( class_exists( 'Rollback_Update_Failure\WP_Upgrader' )
    598             && function_exists( '\Rollback_Update_Failure\move_dir' )
    599         ) {
    600             /*
    601              * If the {@link https://wordpress.org/plugins/rollback-update-failure/ Rollback Update Failure}
    602              * feature plugin is installed, use the move_dir() function from there for better performance.
    603              * Instead of copying a directory from one location to another, it uses the rename() PHP function
    604              * to speed up the process. If the renaming failed, it falls back to copy_dir().
    605              *
    606              * This condition aims to facilitate broader testing of the Rollbacks (temp backups) feature project.
    607              * It is temporary, until the plugin is merged into core.
    608              */
    609             $result = \Rollback_Update_Failure\move_dir( $source, $remote_destination );
    610         } else {
    611             $result = copy_dir( $source, $remote_destination );
    612         }
    613 
    614         if ( is_wp_error( $result ) ) {
    615             if ( $args['clear_working'] ) {
    616                 $wp_filesystem->delete( $remote_source, true );
    617             }
    618             return $result;
    619         }
     597        $result = copy_dir( $source, $remote_destination );
    620598
    621599        // Clear the working folder?
    622600        if ( $args['clear_working'] ) {
    623601            $wp_filesystem->delete( $remote_source, true );
     602        }
     603
     604        if ( is_wp_error( $result ) ) {
     605            return $result;
    624606        }
    625607
Note: See TracChangeset for help on using the changeset viewer.