Parse absolute paths out of error data. see #22704.

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


git-svn-id: http://core.svn.wordpress.org/trunk@25693 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Nacin 2013-10-14 22:25:08 +00:00
parent 4dcca90887
commit 9b56d4d11f
2 changed files with 11 additions and 9 deletions

View File

@ -645,7 +645,7 @@ function _unzip_file_ziparchive($file, $to, $needed_dirs = array() ) {
// Create those directories if need be:
foreach ( $needed_dirs as $_dir ) {
if ( ! $wp_filesystem->mkdir($_dir, FS_CHMOD_DIR) && ! $wp_filesystem->is_dir($_dir) ) // Only check to see if the Dir exists upon creation failure. Less I/O this way.
return new WP_Error( 'mkdir_failed_ziparchive', __( 'Could not create directory.' ), $_dir );
return new WP_Error( 'mkdir_failed_ziparchive', __( 'Could not create directory.' ), substr( $_dir, strlen( $to ) ) );
}
unset($needed_dirs);
@ -664,7 +664,7 @@ function _unzip_file_ziparchive($file, $to, $needed_dirs = array() ) {
return new WP_Error( 'extract_failed_ziparchive', __( 'Could not extract file from archive.' ), $info['name'] );
if ( ! $wp_filesystem->put_contents( $to . $info['name'], $contents, FS_CHMOD_FILE) )
return new WP_Error( 'copy_failed_ziparchive', __( 'Could not copy file.' ), $to . $info['name'] );
return new WP_Error( 'copy_failed_ziparchive', __( 'Could not copy file.' ), $info['name'] );
}
$z->close();
@ -744,8 +744,8 @@ function _unzip_file_pclzip($file, $to, $needed_dirs = array()) {
// Create those directories if need be:
foreach ( $needed_dirs as $_dir ) {
if ( ! $wp_filesystem->mkdir($_dir, FS_CHMOD_DIR) && ! $wp_filesystem->is_dir($_dir) ) // Only check to see if the dir exists upon creation failure. Less I/O this way.
return new WP_Error( 'mkdir_failed_pclzip', __( 'Could not create directory.' ), $_dir );
// if ( ! $wp_filesystem->mkdir($_dir, FS_CHMOD_DIR) && ! $wp_filesystem->is_dir($_dir) ) // Only check to see if the dir exists upon creation failure. Less I/O this way.
return new WP_Error( 'mkdir_failed_pclzip', __( 'Could not create directory.' ), substr( $_dir, strlen( $to ) ) );
}
unset($needed_dirs);
@ -758,7 +758,7 @@ function _unzip_file_pclzip($file, $to, $needed_dirs = array()) {
continue;
if ( ! $wp_filesystem->put_contents( $to . $file['filename'], $file['content'], FS_CHMOD_FILE) )
return new WP_Error( 'copy_failed_pclzip', __( 'Could not copy file.' ), $to . $file['filename'] );
return new WP_Error( 'copy_failed_pclzip', __( 'Could not copy file.' ), $file['filename'] );
}
return true;
}

View File

@ -716,6 +716,8 @@ function update_core($from, $to) {
apply_filters( 'update_feedback', __( 'Copying the required files…' ) );
// Copy new versions of WP files into place.
$result = _copy_dir( $from . $distro, $to, $skip );
if ( is_wp_error( $result ) )
$result = new WP_Error( $result->get_error_code(), $result->get_error_message(), substr( $result->get_error_data(), strlen( $to ) ) );
// Check to make sure everything copied correctly, ignoring the contents of wp-content
$skip = array( 'wp-content' );
@ -744,11 +746,11 @@ function update_core($from, $to) {
// Unlikely to be hit due to the check in unzip_file().
$available_space = disk_free_space( ABSPATH );
if ( $available_space && $total_size >= $available_space ) {
$result = new WP_Error( 'disk_full', __( 'There is not enough free disk space to complete the update.' ), $to );
$result = new WP_Error( 'disk_full', __( 'There is not enough free disk space to complete the update.' ) );
} else {
$result = _copy_dir( $from . $distro, $to, $skip );
if ( is_wp_error( $result ) )
$result = new WP_Error( $result->get_error_code() . '_retry', $result->get_error_message(), $result->get_error_data() );
$result = new WP_Error( $result->get_error_code() . '_retry', $result->get_error_message(), substr( $result->get_error_data(), strlen( $to ) ) );
}
}
@ -770,7 +772,7 @@ function update_core($from, $to) {
if ( $wp_lang_dir ) {
$result = copy_dir($from . $distro . 'wp-content/languages/', $wp_lang_dir);
if ( is_wp_error( $result ) )
$result = new WP_Error( $result->get_error_code() . '_languages', $result->get_error_message(), $result->get_error_data() );
$result = new WP_Error( $result->get_error_code() . '_languages', $result->get_error_message(), substr( $result->get_error_data(), strlen( $wp_lang_dir ) ) );
}
}
}
@ -820,7 +822,7 @@ function update_core($from, $to) {
if ( is_wp_error( $_result ) ) {
if ( ! is_wp_error( $result ) )
$result = new WP_Error;
$result->add( $_result->get_error_code() . "_$type", $_result->get_error_message(), $_result->get_error_data() );
$result->add( $_result->get_error_code() . "_$type", $_result->get_error_message(), substr( $_result->get_error_data(), strlen( $dest ) ) );
}
}
}