Fallback to PclZip in the event that ZipArchive cannot handle a given archive properly. Close the Zip handle when we're done as well. Fixes #12230
git-svn-id: https://develop.svn.wordpress.org/trunk@13221 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
32ad16e1e8
commit
343447e5a0
@ -528,10 +528,18 @@ function unzip_file($file, $to) {
|
||||
}
|
||||
}
|
||||
|
||||
if ( class_exists('ZipArchive') && apply_filters('unzip_file_use_ziparchive', true ) )
|
||||
return _unzip_file_ziparchive($file, $to, $needed_dirs);
|
||||
else
|
||||
return _unzip_file_pclzip($file, $to, $needed_dirs);
|
||||
if ( class_exists('ZipArchive') && apply_filters('unzip_file_use_ziparchive', true ) ) {
|
||||
$result = _unzip_file_ziparchive($file, $to, $needed_dirs);
|
||||
if ( true === $result ) {
|
||||
return $result;
|
||||
} elseif ( is_wp_error($result) ) {
|
||||
if ( 'incompatible_archive' != $result->get_error_code() )
|
||||
return $result;
|
||||
}
|
||||
echo "fall through to pcl";
|
||||
}
|
||||
// Fall through to PclZip if ZipArchive is not available, or encountered an error opening the file.
|
||||
return _unzip_file_pclzip($file, $to, $needed_dirs);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -591,6 +599,8 @@ function _unzip_file_ziparchive($file, $to, $needed_dirs = array() ) {
|
||||
return new WP_Error('copy_failed', __('Could not copy file.'), $to . $file['filename']);
|
||||
}
|
||||
|
||||
$z->close();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user