diff --git a/wp-admin/includes/class-wp-upgrader.php b/wp-admin/includes/class-wp-upgrader.php index 2437ac9625..1b2df949cf 100644 --- a/wp-admin/includes/class-wp-upgrader.php +++ b/wp-admin/includes/class-wp-upgrader.php @@ -588,15 +588,19 @@ class WP_Upgrader { } /* - * Partial updates may want to retain the destination. - * move_dir() returns a WP_Error when the destination exists, - * so copy_dir() should be used. + * If 'clear_working' is false, the source should not be removed, so use copy_dir() instead. * - * If 'clear_working' is false, the source shouldn't be removed. - * After move_dir() runs, the source will no longer exist. - * Therefore, copy_dir() should be used. + * Partial updates, like language packs, may want to retain the destination. + * If the destination exists or has contents, this may be a partial update, + * and the destination should not be removed, so use copy_dir() instead. */ - if ( $clear_destination && $args['clear_working'] ) { + if ( $args['clear_working'] + && ( + // Destination does not exist or has no contents. + ! $wp_filesystem->exists( $remote_destination ) + || empty( $wp_filesystem->dirlist( $remote_destination ) ) + ) + ) { $result = move_dir( $source, $remote_destination, true ); } else { // Create destination if needed. diff --git a/wp-includes/version.php b/wp-includes/version.php index 6b7b26f060..f1bfca4c0e 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.2-alpha-55228'; +$wp_version = '6.2-alpha-55229'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.