Ticket #14999: 14999.diff
| File 14999.diff, 2.5 KB (added by dd32, 21 months ago) |
|---|
-
wp-admin/includes/class-wp-upgrader.php
48 48 /* translators: %s: directory name */ 49 49 $this->strings['fs_no_folder'] = __('Unable to locate needed folder (%s).'); 50 50 51 $this->strings['incompatible_archive'] = __('The package is corrupt or not compatible with the system. Please try again.'); 52 51 53 $this->strings['download_failed'] = __('Download failed.'); 52 54 $this->strings['installing_package'] = __('Installing the latest version…'); 53 55 $this->strings['folder_exists'] = __('Destination folder already exists.'); … … 153 155 154 156 if ( is_wp_error($result) ) { 155 157 $wp_filesystem->delete($working_dir, true); 158 if ( 'incompatible_archive' == $result->get_error_code() ) { 159 return new WP_Error( 'incompatible_archive', $this->strings['incompatible_archive'], $result->get_error_data() ); 160 } 156 161 return $result; 157 162 } 158 163 … … 624 629 $this->strings['installing_package'] = __('Installing the theme…'); 625 630 $this->strings['process_failed'] = __('Theme install failed.'); 626 631 $this->strings['process_success'] = __('Theme installed successfully.'); 632 $this->strings['wrong_format'] = __('The provided package is not in the required format.'); 627 633 } 628 634 635 function unpack_package($package, $delete_package = true) { 636 global $wp_filesystem; 637 $working_dir = parent::unpack_package($package, $delete_package); 638 639 if ( is_wp_error($working_dir) ) 640 return $working_dir; 641 642 $problem = false; 643 $dirlist = $wp_filesystem->dirlist( $working_dir ); 644 unset( $dirlist[ '__MAC_OSX' ] ); // Some mac archives have a meta directory we need to exclude fromthis check 645 646 if ( !$dirlist || count($dirlist) > 1 ) { // A proper archive should have a single directory entry 647 $problem = true; 648 } else { 649 $folder = array_shift( array_keys($dirlist) ); 650 $dirlist = $wp_filesystem->dirlist( $working_dir . '/' . $folder ); 651 652 if ( ! isset($dirlist[ 'style.css' ]) ) // A proper archive should have a style.css file in the single subdirectory 653 $problem = true; 654 // Check file header meta too? 655 } 656 657 // Check the extracted files are in the correct format. 658 if ( $problem ) { 659 $wp_filesystem->delete($working_dir, true); 660 return new WP_Error('wrong_format', $this->strings['wrong_format']); 661 } 662 663 return $working_dir; 664 } 665 629 666 function install($package) { 630 667 631 668 $this->init();
