Upgrade/Install: Fix moving plugins folder in `WP_Upgrader:: move_to_temp_backup_dir()`.

[51815] introduced the creation of a temporary backup of plugins before updating.

The `move()` (and later, `move_dir()`) call) uses a `$src` parameter.
For Hello Dolly, this is `<path>/wp-contents/plugins/.` (note the period at the end).

For users on Linux and Mac, this doesn't appear to cause any problems.
However, on Windows, the move causes the plugins folder to be moved which then causes a failure when attempting to call `mkdir()`.

This commit skips any plugin whose slug is `'.'` as this slug results in the `$src` value ending in a period. 

Follow-up to [51815].

Props costdev, boniu91, hellofromTonya.
Fixes #54543.
Built from https://develop.svn.wordpress.org/trunk@52337


git-svn-id: http://core.svn.wordpress.org/trunk@51929 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
hellofromTonya 2021-12-07 16:51:03 +00:00
parent ec25c4ee57
commit 4f0c8ef665
2 changed files with 12 additions and 1 deletions

View File

@ -1025,6 +1025,17 @@ class WP_Upgrader {
return false; return false;
} }
/**
* Skip any plugin that has "." as its slug.
* A slug of "." will result in a `$src` value ending in a period.
*
* On Windows, this will cause the 'plugins' folder to be moved,
* and will cause a failure when attempting to call `mkdir()`.
*/
if ( '.' === $args['slug'] ) {
return false;
}
$dest_dir = $wp_filesystem->wp_content_dir() . 'upgrade/temp-backup/'; $dest_dir = $wp_filesystem->wp_content_dir() . 'upgrade/temp-backup/';
// Create the temp-backup directory if it doesn't exist. // Create the temp-backup directory if it doesn't exist.
if ( ( if ( (

View File

@ -16,7 +16,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '5.9-beta1-52336'; $wp_version = '5.9-beta1-52337';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.