mirror of
https://github.com/WordPress/WordPress.git
synced 2024-10-30 07:20:01 +01:00
Upgrade/Install: Return WP_Error when source files cannot be found.
Fixes a fatal error in `array_keys()` (PHP 8.0+) as `$wp_filesystem->dirlist()` will return `false` when the source directory doesn't exist or becomes unreadable for some reason. Props: verygoode, lifelightweb, da5f656f, costdev, afragen, azaozz Fixes #61114 Built from https://develop.svn.wordpress.org/trunk@59257 git-svn-id: http://core.svn.wordpress.org/trunk@58649 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
5c8c27b24b
commit
e52423e435
@ -204,6 +204,7 @@ class WP_Upgrader {
|
|||||||
$this->strings['mkdir_failed'] = __( 'Could not create directory.' );
|
$this->strings['mkdir_failed'] = __( 'Could not create directory.' );
|
||||||
$this->strings['incompatible_archive'] = __( 'The package could not be installed.' );
|
$this->strings['incompatible_archive'] = __( 'The package could not be installed.' );
|
||||||
$this->strings['files_not_writable'] = __( 'The update cannot be installed because some files could not be copied. This is usually due to inconsistent file permissions.' );
|
$this->strings['files_not_writable'] = __( 'The update cannot be installed because some files could not be copied. This is usually due to inconsistent file permissions.' );
|
||||||
|
$this->strings['dir_not_readable'] = __( 'A directory could not be read.' );
|
||||||
|
|
||||||
$this->strings['maintenance_start'] = __( 'Enabling Maintenance mode…' );
|
$this->strings['maintenance_start'] = __( 'Enabling Maintenance mode…' );
|
||||||
$this->strings['maintenance_end'] = __( 'Disabling Maintenance mode…' );
|
$this->strings['maintenance_end'] = __( 'Disabling Maintenance mode…' );
|
||||||
@ -558,7 +559,13 @@ class WP_Upgrader {
|
|||||||
$remote_source = $args['source'];
|
$remote_source = $args['source'];
|
||||||
$local_destination = $destination;
|
$local_destination = $destination;
|
||||||
|
|
||||||
$source_files = array_keys( $wp_filesystem->dirlist( $remote_source ) );
|
$dirlist = $wp_filesystem->dirlist( $remote_source );
|
||||||
|
|
||||||
|
if ( false === $dirlist ) {
|
||||||
|
return new WP_Error( 'source_read_failed', $this->strings['fs_error'], $this->strings['dir_not_readable'] );
|
||||||
|
}
|
||||||
|
|
||||||
|
$source_files = array_keys( $dirlist );
|
||||||
$remote_destination = $wp_filesystem->find_folder( $local_destination );
|
$remote_destination = $wp_filesystem->find_folder( $local_destination );
|
||||||
|
|
||||||
// Locate which directory to copy to the new folder. This is based on the actual folder holding the files.
|
// Locate which directory to copy to the new folder. This is based on the actual folder holding the files.
|
||||||
@ -605,7 +612,13 @@ class WP_Upgrader {
|
|||||||
|
|
||||||
// Has the source location changed? If so, we need a new source_files list.
|
// Has the source location changed? If so, we need a new source_files list.
|
||||||
if ( $source !== $remote_source ) {
|
if ( $source !== $remote_source ) {
|
||||||
$source_files = array_keys( $wp_filesystem->dirlist( $source ) );
|
$dirlist = $wp_filesystem->dirlist( $source );
|
||||||
|
|
||||||
|
if ( false === $dirlist ) {
|
||||||
|
return new WP_Error( 'new_source_read_failed', $this->strings['fs_error'], $this->strings['dir_not_readable'] );
|
||||||
|
}
|
||||||
|
|
||||||
|
$source_files = array_keys( $dirlist );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '6.7-beta3-59256';
|
$wp_version = '6.7-beta3-59257';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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.
|
||||||
|
Loading…
Reference in New Issue
Block a user