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

The [https://make.wordpress.org/core/2021/02/19/feature-plugin-rollback-update-failure/ 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 [https://wordpress.org/plugins/rollback-update-failure/ 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.
Built from https://develop.svn.wordpress.org/trunk@53578


git-svn-id: http://core.svn.wordpress.org/trunk@53167 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2022-06-26 12:37:18 +00:00
parent d533b76ef8
commit 79efd59bca
2 changed files with 18 additions and 2 deletions

View File

@ -593,7 +593,23 @@ class WP_Upgrader {
}
// Copy new version of item into place.
$result = copy_dir( $source, $remote_destination );
if ( class_exists( 'Rollback_Update_Failure\WP_Upgrader' )
&& function_exists( '\Rollback_Update_Failure\move_dir' )
) {
/*
* If the {@link https://wordpress.org/plugins/rollback-update-failure/ Rollback Update Failure}
* feature plugin is installed, 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. If the renaming failed, it falls back to copy_dir().
*
* This condition aims to facilitate broader testing of the Rollbacks (temp backups) feature project.
* It is temporary, until the plugin is merged into core.
*/
$result = \Rollback_Update_Failure\move_dir( $source, $remote_destination );
} else {
$result = copy_dir( $source, $remote_destination );
}
if ( is_wp_error( $result ) ) {
if ( $args['clear_working'] ) {
$wp_filesystem->delete( $remote_source, true );

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.1-alpha-53577';
$wp_version = '6.1-alpha-53578';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.