mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-23 01:27:36 +01:00
Upgrade/Install: Introduce a move_dir()
function.
This replaces the `copy_dir()` usage in `WP_Upgrader::install_package()` and aims to avoid PHP timeout issues when installing or updating large plugins on slower systems like Vagrant or the WP Docker test environment. The new function attempts a native PHP `rename()` function first and falls back to the previous `copy_dir()`. Follow-up to [51815], [51898]. Props afragen, aristath, peterwilsoncc, galbaras, noisysocks, pbiron. Fixes #54166. See #51857. Built from https://develop.svn.wordpress.org/trunk@51899 git-svn-id: http://core.svn.wordpress.org/trunk@51492 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
0f2d2264b5
commit
d5887aeec3
@ -623,8 +623,8 @@ class WP_Upgrader {
|
||||
}
|
||||
}
|
||||
|
||||
// Copy new version of item into place.
|
||||
$result = copy_dir( $source, $remote_destination );
|
||||
// Move new version of item into place.
|
||||
$result = move_dir( $source, $remote_destination );
|
||||
if ( is_wp_error( $result ) ) {
|
||||
if ( $args['clear_working'] ) {
|
||||
$wp_filesystem->delete( $remote_source, true );
|
||||
|
@ -1917,6 +1917,34 @@ function copy_dir( $from, $to, $skip_list = array() ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves a directory from one location to another via the rename() PHP function.
|
||||
* If the renaming failed, falls back to copy_dir().
|
||||
*
|
||||
* Assumes that WP_Filesystem() has already been called and setup.
|
||||
*
|
||||
* @since 5.9.0
|
||||
*
|
||||
* @global WP_Filesystem_Base $wp_filesystem WordPress filesystem subclass.
|
||||
*
|
||||
* @param string $from Source directory.
|
||||
* @param string $to Destination directory.
|
||||
* @return true|WP_Error True on success, WP_Error on failure.
|
||||
*/
|
||||
function move_dir( $from, $to ) {
|
||||
global $wp_filesystem;
|
||||
|
||||
$wp_filesystem->rmdir( $to );
|
||||
if ( @rename( $from, $to ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$wp_filesystem->mkdir( $to );
|
||||
$result = copy_dir( $from, $to );
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes and connects the WordPress Filesystem Abstraction classes.
|
||||
*
|
||||
|
@ -16,7 +16,7 @@
|
||||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '5.9-alpha-51898';
|
||||
$wp_version = '5.9-alpha-51899';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
Loading…
Reference in New Issue
Block a user