| 1 | Index: wp-admin/includes/file.php |
|---|
| 2 | =================================================================== |
|---|
| 3 | --- wp-admin/includes/file.php (revision 13162) |
|---|
| 4 | +++ wp-admin/includes/file.php (working copy) |
|---|
| 5 | @@ -528,10 +528,13 @@ |
|---|
| 6 | } |
|---|
| 7 | } |
|---|
| 8 | |
|---|
| 9 | - if ( class_exists('ZipArchive') && apply_filters('unzip_file_use_ziparchive', true ) ) |
|---|
| 10 | - return _unzip_file_ziparchive($file, $to, $needed_dirs); |
|---|
| 11 | - else |
|---|
| 12 | - return _unzip_file_pclzip($file, $to, $needed_dirs); |
|---|
| 13 | + if ( class_exists('ZipArchive') && apply_filters('unzip_file_use_ziparchive', true ) ) { |
|---|
| 14 | + $result = _unzip_file_ziparchive($file, $to, $needed_dirs); |
|---|
| 15 | + if ( $result ) // true || WP_Error |
|---|
| 16 | + return $result; |
|---|
| 17 | + } |
|---|
| 18 | + // Fall through to PclZip if ZipArchive is not available, or encountered an error opening the file. |
|---|
| 19 | + return _unzip_file_pclzip($file, $to, $needed_dirs); |
|---|
| 20 | } |
|---|
| 21 | |
|---|
| 22 | /** |
|---|
| 23 | @@ -545,7 +548,7 @@ |
|---|
| 24 | * @param string $file Full path and filename of zip archive |
|---|
| 25 | * @param string $to Full path on the filesystem to extract archive to |
|---|
| 26 | * @param array $needed_dirs A partial list of required folders needed to be created. |
|---|
| 27 | - * @return mixed WP_Error on failure, True on success |
|---|
| 28 | + * @return mixed WP_Error|false}true WP_Error for failure codes, false if the archive could not be read, true for success. |
|---|
| 29 | */ |
|---|
| 30 | function _unzip_file_ziparchive($file, $to, $needed_dirs = array() ) { |
|---|
| 31 | global $wp_filesystem; |
|---|
| 32 | @@ -554,7 +557,7 @@ |
|---|
| 33 | |
|---|
| 34 | // PHP4-compat - php4 classes can't contain constants |
|---|
| 35 | if ( true !== $z->open($file, /* ZIPARCHIVE::CHECKCONS */ 4) ) |
|---|
| 36 | - return new WP_Error('incompatible_archive', __('Incompatible Archive.')); |
|---|
| 37 | + return false; |
|---|
| 38 | |
|---|
| 39 | for ( $i = 0; $i < $z->numFiles; $i++ ) { |
|---|
| 40 | if ( ! $info = $z->statIndex($i) ) |
|---|
| 41 | @@ -591,6 +594,8 @@ |
|---|
| 42 | return new WP_Error('copy_failed', __('Could not copy file.'), $to . $file['filename']); |
|---|
| 43 | } |
|---|
| 44 | |
|---|
| 45 | + $z->close(); |
|---|
| 46 | + |
|---|
| 47 | return true; |
|---|
| 48 | } |
|---|
| 49 | |
|---|