Ticket #22704: 22704.7.diff
| File 22704.7.diff, 11.2 KB (added by , 12 years ago) |
|---|
-
class-wp-upgrader.php
213 213 if ( 1 == count($source_files) && $wp_filesystem->is_dir( trailingslashit($source) . $source_files[0] . '/') ) //Only one folder? Then we want its contents. 214 214 $source = trailingslashit($source) . trailingslashit($source_files[0]); 215 215 elseif ( count($source_files) == 0 ) 216 return new WP_Error( 'incompatible_archive ', $this->strings['incompatible_archive'], $this->strings['no_files'] ); //There are no files?216 return new WP_Error( 'incompatible_archive_empty', $this->strings['incompatible_archive'], $this->strings['no_files'] ); //There are no files? 217 217 else //It's only a single file, the upgrader will use the foldername of this file as the destination folder. foldername is based on zip filename. 218 218 $source = trailingslashit($source); 219 219 … … 262 262 //Create destination if needed 263 263 if ( !$wp_filesystem->exists($remote_destination) ) 264 264 if ( !$wp_filesystem->mkdir($remote_destination, FS_CHMOD_DIR) ) 265 return new WP_Error('mkdir_failed ', $this->strings['mkdir_failed'], $remote_destination);265 return new WP_Error('mkdir_failed_destination', $this->strings['mkdir_failed'], $remote_destination); 266 266 267 267 // Copy new version of item into place. 268 268 $result = copy_dir($source, $remote_destination); … … 623 623 } 624 624 625 625 if ( ! $plugins_found ) 626 return new WP_Error( 'incompatible_archive ', $this->strings['incompatible_archive'], __('No valid plugins were found.') );626 return new WP_Error( 'incompatible_archive_no_plugins', $this->strings['incompatible_archive'], __('No valid plugins were found.') ); 627 627 628 628 return $source; 629 629 } … … 989 989 990 990 // A proper archive should have a style.css file in the single subdirectory 991 991 if ( ! file_exists( $working_directory . 'style.css' ) ) 992 return new WP_Error( 'incompatible_archive ', $this->strings['incompatible_archive'], __('The theme is missing the <code>style.css</code> stylesheet.') );992 return new WP_Error( 'incompatible_archive_theme_no_style', $this->strings['incompatible_archive'], __('The theme is missing the <code>style.css</code> stylesheet.') ); 993 993 994 994 $info = get_file_data( $working_directory . 'style.css', array( 'Name' => 'Theme Name', 'Template' => 'Template' ) ); 995 995 996 996 if ( empty( $info['Name'] ) ) 997 return new WP_Error( 'incompatible_archive ', $this->strings['incompatible_archive'], __("The <code>style.css</code> stylesheet doesn't contain a valid theme header.") );997 return new WP_Error( 'incompatible_archive_theme_no_name', $this->strings['incompatible_archive'], __("The <code>style.css</code> stylesheet doesn't contain a valid theme header.") ); 998 998 999 999 // If it's not a child theme, it must have at least an index.php to be legit. 1000 1000 if ( empty( $info['Template'] ) && ! file_exists( $working_directory . 'index.php' ) ) 1001 return new WP_Error( 'incompatible_archive ', $this->strings['incompatible_archive'], __('The theme is missing the <code>index.php</code> file.') );1001 return new WP_Error( 'incompatible_archive_theme_no_index', $this->strings['incompatible_archive'], __('The theme is missing the <code>index.php</code> file.') ); 1002 1002 1003 1003 return $source; 1004 1004 } … … 1141 1141 $remote_destination = $wp_filesystem->find_folder( WP_LANG_DIR ); 1142 1142 if ( ! $wp_filesystem->exists( $remote_destination ) ) 1143 1143 if ( ! $wp_filesystem->mkdir( $remote_destination, FS_CHMOD_DIR ) ) 1144 return new WP_Error( 'mkdir_failed ', $this->strings['mkdir_failed'], $remote_destination );1144 return new WP_Error( 'mkdir_failed_lang_dir', $this->strings['mkdir_failed'], $remote_destination ); 1145 1145 1146 1146 foreach ( $language_updates as $language_update ) { 1147 1147 … … 1200 1200 } 1201 1201 1202 1202 if ( ! $mo || ! $po ) 1203 return new WP_Error( 'incompatible_archive ', $this->strings['incompatible_archive'],1203 return new WP_Error( 'incompatible_archive_pomo', $this->strings['incompatible_archive'], 1204 1204 __( 'The language pack is missing either the <code>.po</code> or <code>.mo</code> files.' ) ); 1205 1205 1206 1206 return $source; … … 1287 1287 // Copy update-core.php from the new version into place. 1288 1288 if ( !$wp_filesystem->copy($working_dir . '/wordpress/wp-admin/includes/update-core.php', $wp_dir . 'wp-admin/includes/update-core.php', true) ) { 1289 1289 $wp_filesystem->delete($working_dir, true); 1290 return new WP_Error('copy_failed ', $this->strings['copy_failed']);1290 return new WP_Error('copy_failed_for_update_core_file', $this->strings['copy_failed']); 1291 1291 } 1292 1292 $wp_filesystem->chmod($wp_dir . 'wp-admin/includes/update-core.php', FS_CHMOD_FILE); 1293 1293 -
file.php
603 603 604 604 for ( $i = 0; $i < $z->numFiles; $i++ ) { 605 605 if ( ! $info = $z->statIndex($i) ) 606 return new WP_Error('stat_failed ', __('Could not retrieve file from archive.'));606 return new WP_Error('stat_failed_ziparchive', __('Could not retrieve file from archive.')); 607 607 608 608 if ( '__MACOSX/' === substr($info['name'], 0, 9) ) // Skip the OS X-created __MACOSX directory 609 609 continue; … … 633 633 // Create those directories if need be: 634 634 foreach ( $needed_dirs as $_dir ) { 635 635 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. 636 return new WP_Error('mkdir_failed ', __('Could not create directory.'), $_dir);636 return new WP_Error('mkdir_failed_ziparchive', __('Could not create directory.'), $_dir); 637 637 } 638 638 unset($needed_dirs); 639 639 640 640 for ( $i = 0; $i < $z->numFiles; $i++ ) { 641 641 if ( ! $info = $z->statIndex($i) ) 642 return new WP_Error('stat_failed ', __('Could not retrieve file from archive.'));642 return new WP_Error('stat_failed_ziparchive', __('Could not retrieve file from archive.')); 643 643 644 644 if ( '/' == substr($info['name'], -1) ) // directory 645 645 continue; … … 649 649 650 650 $contents = $z->getFromIndex($i); 651 651 if ( false === $contents ) 652 return new WP_Error('extract_failed ', __('Could not extract file from archive.'), $info['name']);652 return new WP_Error('extract_failed_ziparchive', __('Could not extract file from archive.'), $info['name']); 653 653 654 654 if ( ! $wp_filesystem->put_contents( $to . $info['name'], $contents, FS_CHMOD_FILE) ) 655 return new WP_Error('copy_failed ', __('Could not copy file.'), $to . $info['name']);655 return new WP_Error('copy_failed_ziparchive', __('Could not copy file.'), $to . $info['name']); 656 656 } 657 657 658 658 $z->close(); … … 691 691 return new WP_Error('incompatible_archive', __('Incompatible Archive.'), $archive->errorInfo(true)); 692 692 693 693 if ( 0 == count($archive_files) ) 694 return new WP_Error('empty_archive ', __('Empty archive.'));694 return new WP_Error('empty_archive_pclzip', __('Empty archive.')); 695 695 696 696 // Determine any children directories needed (From within the archive) 697 697 foreach ( $archive_files as $file ) { … … 720 720 // Create those directories if need be: 721 721 foreach ( $needed_dirs as $_dir ) { 722 722 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. 723 return new WP_Error('mkdir_failed ', __('Could not create directory.'), $_dir);723 return new WP_Error('mkdir_failed_pclzip', __('Could not create directory.'), $_dir); 724 724 } 725 725 unset($needed_dirs); 726 726 … … 733 733 continue; 734 734 735 735 if ( ! $wp_filesystem->put_contents( $to . $file['filename'], $file['content'], FS_CHMOD_FILE) ) 736 return new WP_Error('copy_failed ', __('Could not copy file.'), $to . $file['filename']);736 return new WP_Error('copy_failed_pclzip', __('Could not copy file.'), $to . $file['filename']); 737 737 } 738 738 return true; 739 739 } … … 766 766 // If copy failed, chmod file to 0644 and try again. 767 767 $wp_filesystem->chmod($to . $filename, 0644); 768 768 if ( ! $wp_filesystem->copy($from . $filename, $to . $filename, true, FS_CHMOD_FILE) ) 769 return new WP_Error('copy_failed ', __('Could not copy file.'), $to . $filename);769 return new WP_Error('copy_failed_copy_dir', __('Could not copy file.'), $to . $filename); 770 770 } 771 771 } elseif ( 'd' == $fileinfo['type'] ) { 772 772 if ( !$wp_filesystem->is_dir($to . $filename) ) { 773 773 if ( !$wp_filesystem->mkdir($to . $filename, FS_CHMOD_DIR) ) 774 return new WP_Error('mkdir_failed ', __('Could not create directory.'), $to . $filename);774 return new WP_Error('mkdir_failed_copy_dir', __('Could not create directory.'), $to . $filename); 775 775 } 776 776 777 777 // generate the $sub_skip_list for the subdirectory as a sub-set of the existing $skip_list -
update-core.php
661 661 $versions_file = trailingslashit( $wp_filesystem->wp_content_dir() ) . 'upgrade/version-current.php'; 662 662 if ( ! $wp_filesystem->copy( $from . $distro . 'wp-includes/version.php', $versions_file ) ) { 663 663 $wp_filesystem->delete( $from, true ); 664 return new WP_Error( 'copy_failed ', __('Could not copy file.') );664 return new WP_Error( 'copy_failed_for_version_file', __('Could not copy file.') ); 665 665 } 666 666 667 667 $wp_filesystem->chmod( $versions_file, FS_CHMOD_FILE ); … … 741 741 $total_size += filesize( $working_dir_local . '/' . $file ); 742 742 743 743 // If we don't have enough free space, it isn't worth trying again 744 if ( $total_size >= disk_free_space( ABSPATH ) ) 744 if ( $total_size >= disk_free_space( ABSPATH ) ) { 745 745 $result = new WP_Error( 'disk_full', __( 'There is not enough free disk space to complete the update.' ), $to ); 746 else746 } else { 747 747 $result = _copy_dir( $from . $distro, $to, $skip ); 748 if ( is_wp_error( $result ) ) 749 $result = new WP_Error( $result->get_error_code() . '_retry', $result->get_error_message(), $result->get_error_data() ); 750 } 748 751 } 749 752 750 753 // Custom Content Directory needs updating now. … … 800 803 continue; 801 804 802 805 if ( ! $wp_filesystem->copy($from . $distro . 'wp-content/' . $file, $dest . $filename, FS_CHMOD_FILE) ) 803 $result = new WP_Error('copy_failed ', __('Could not copy file.'), $dest . $filename);806 $result = new WP_Error('copy_failed_for_new_bundled', __('Could not copy file.'), $dest . $filename); 804 807 } else { 805 808 if ( ! $development_build && $wp_filesystem->is_dir( $dest . $filename ) ) 806 809 continue; … … 887 890 // If copy failed, chmod file to 0644 and try again. 888 891 $wp_filesystem->chmod($to . $filename, 0644); 889 892 if ( ! $wp_filesystem->copy($from . $filename, $to . $filename, true, FS_CHMOD_FILE) ) 890 return new WP_Error('copy_failed ', __('Could not copy file.'), $to . $filename);893 return new WP_Error('copy_failed__copy_dir', __('Could not copy file.'), $to . $filename); 891 894 } 892 895 } elseif ( 'd' == $fileinfo['type'] ) { 893 896 if ( !$wp_filesystem->is_dir($to . $filename) ) { 894 897 if ( !$wp_filesystem->mkdir($to . $filename, FS_CHMOD_DIR) ) 895 return new WP_Error('mkdir_failed ', __('Could not create directory.'), $to . $filename);898 return new WP_Error('mkdir_failed__copy_dir', __('Could not create directory.'), $to . $filename); 896 899 } 897 900 898 901 // generate the $sub_skip_list for the subdirectory as a sub-set of the existing $skip_list