Upgrade/Install: Provide dirpath in error messages when `_unzip_file_pclzip()` cannot create directories.

This changeset ensures the directory path is provided in error messages when `_unzip_file_pclzip()` is unable to create a directory. This removes `substr()` which was returning an empty string in some use cases.

Props gunterer, SergeyBiryukov, n8finch, peterwilsoncc, audrasjb, rsiddharth, costdev , desrosj, mukesh27.
Fixes #54477.

Built from https://develop.svn.wordpress.org/trunk@54442


git-svn-id: http://core.svn.wordpress.org/trunk@54001 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
audrasjb 2022-10-10 12:48:14 +00:00
parent f4521ee2a1
commit c5f189c4a1
2 changed files with 3 additions and 3 deletions

View File

@ -1707,7 +1707,7 @@ function _unzip_file_ziparchive( $file, $to, $needed_dirs = array() ) {
foreach ( $needed_dirs as $_dir ) {
// Only check to see if the Dir exists upon creation failure. Less I/O this way.
if ( ! $wp_filesystem->mkdir( $_dir, FS_CHMOD_DIR ) && ! $wp_filesystem->is_dir( $_dir ) ) {
return new WP_Error( 'mkdir_failed_ziparchive', __( 'Could not create directory.' ), substr( $_dir, strlen( $to ) ) );
return new WP_Error( 'mkdir_failed_ziparchive', __( 'Could not create directory.' ), $_dir );
}
}
unset( $needed_dirs );
@ -1848,7 +1848,7 @@ function _unzip_file_pclzip( $file, $to, $needed_dirs = array() ) {
foreach ( $needed_dirs as $_dir ) {
// Only check to see if the dir exists upon creation failure. Less I/O this way.
if ( ! $wp_filesystem->mkdir( $_dir, FS_CHMOD_DIR ) && ! $wp_filesystem->is_dir( $_dir ) ) {
return new WP_Error( 'mkdir_failed_pclzip', __( 'Could not create directory.' ), substr( $_dir, strlen( $to ) ) );
return new WP_Error( 'mkdir_failed_pclzip', __( 'Could not create directory.' ), $_dir );
}
}
unset( $needed_dirs );

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.1-beta3-54441';
$wp_version = '6.1-beta3-54442';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.