@@ -1672,6 +1672,7 @@ function _unzip_file_ziparchive( $file, $to, $needed_dirs = array() ) {
1672
1672
$ info = $ z ->statIndex ( $ i );
1673
1673
1674
1674
if ( ! $ info ) {
1675
+ $ z ->close ();
1675
1676
return new WP_Error ( 'stat_failed_ziparchive ' , __ ( 'Could not retrieve file from archive. ' ) );
1676
1677
}
1677
1678
@@ -1709,6 +1710,7 @@ function _unzip_file_ziparchive( $file, $to, $needed_dirs = array() ) {
1709
1710
$ available_space = function_exists ( 'disk_free_space ' ) ? @disk_free_space ( WP_CONTENT_DIR ) : false ;
1710
1711
1711
1712
if ( $ available_space && ( $ required_space > $ available_space ) ) {
1713
+ $ z ->close ();
1712
1714
return new WP_Error (
1713
1715
'disk_full_unzip_file ' ,
1714
1716
__ ( 'Could not copy files. You may have run out of disk space. ' ),
@@ -1746,6 +1748,7 @@ function _unzip_file_ziparchive( $file, $to, $needed_dirs = array() ) {
1746
1748
foreach ( $ needed_dirs as $ _dir ) {
1747
1749
// Only check to see if the Dir exists upon creation failure. Less I/O this way.
1748
1750
if ( ! $ wp_filesystem ->mkdir ( $ _dir , FS_CHMOD_DIR ) && ! $ wp_filesystem ->is_dir ( $ _dir ) ) {
1751
+ $ z ->close ();
1749
1752
return new WP_Error ( 'mkdir_failed_ziparchive ' , __ ( 'Could not create directory. ' ), $ _dir );
1750
1753
}
1751
1754
}
@@ -1774,6 +1777,7 @@ function _unzip_file_ziparchive( $file, $to, $needed_dirs = array() ) {
1774
1777
$ info = $ z ->statIndex ( $ i );
1775
1778
1776
1779
if ( ! $ info ) {
1780
+ $ z ->close ();
1777
1781
return new WP_Error ( 'stat_failed_ziparchive ' , __ ( 'Could not retrieve file from archive. ' ) );
1778
1782
}
1779
1783
@@ -1793,10 +1797,12 @@ function _unzip_file_ziparchive( $file, $to, $needed_dirs = array() ) {
1793
1797
$ contents = $ z ->getFromIndex ( $ i );
1794
1798
1795
1799
if ( false === $ contents ) {
1800
+ $ z ->close ();
1796
1801
return new WP_Error ( 'extract_failed_ziparchive ' , __ ( 'Could not extract file from archive. ' ), $ info ['name ' ] );
1797
1802
}
1798
1803
1799
1804
if ( ! $ wp_filesystem ->put_contents ( $ to . $ info ['name ' ], $ contents , FS_CHMOD_FILE ) ) {
1805
+ $ z ->close ();
1800
1806
return new WP_Error ( 'copy_failed_ziparchive ' , __ ( 'Could not copy file. ' ), $ info ['name ' ] );
1801
1807
}
1802
1808
}
0 commit comments