Skip to content

Commit

Permalink
Upgrade/Install: Send language pack updates to copy_dir().
Browse files Browse the repository at this point in the history
If the `clear_working` flag in `WP_Upgrader::install_package()` is false, the source should not be removed, so `copy_dir()` should be used instead.

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 `copy_dir()` should be used instead.

Follow-up to [55204], [55219], [55220], [55223], [55226].

Props afragen, costdev, swissspidy.
See #57557.
Built from https://develop.svn.wordpress.org/trunk@55229


git-svn-id: http://core.svn.wordpress.org/trunk@54762 1a063a9b-81f0-0310-95a4-ce76da25c4cd
  • Loading branch information
SergeyBiryukov committed Feb 6, 2023
1 parent 5c1f181 commit ba4ed5f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
18 changes: 11 additions & 7 deletions wp-admin/includes/class-wp-upgrader.php
Original file line number Diff line number Diff line change
Expand Up @@ -588,15 +588,19 @@ public function install_package( $args = array() ) {
}

/*
* 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.
Expand Down
2 changes: 1 addition & 1 deletion wp-includes/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit ba4ed5f

Please sign in to comment.