Make WordPress Core

Opened 15 years ago

Closed 14 years ago

#10403 closed enhancement (fixed)

Consider using the PHP ZIP extension to extract Zip's if available

Reported by: dd32's profile dd32 Owned by: dd32's profile dd32
Milestone: 3.0 Priority: normal
Severity: normal Version: 2.9
Component: Upgrade/Install Keywords: featured
Focuses: Cc:


WordPress should use the PHP Zip extension if available to decompress zip files, It should be more efficient than a PHP-based uncompress routine..

Change History (13)

#1 @peaceablewhale
15 years ago

  • Keywords needs-patch added

+1. The extension is automatically installed in PHP Windows releases since 5.3.0.

#2 @dd32
15 years ago

If someone else doesnt implement this, i'll get it done before next release.. I've got other uses for that code :)

#3 @peaceablewhale
15 years ago

  • Keywords needs-patch removed

Then leaving this to you should be the best. The "needs-patch" keyboard is no longer needed :)

#4 @dd32
15 years ago

  • Status changed from new to accepted

#6 @Denis-de-Bernardy
14 years ago

  • Keywords bug-hunt added

#7 @Denis-de-Bernardy
14 years ago

  • Keywords featured added; bug-hunt removed

#8 @dd32
14 years ago

  • Milestone changed from Future Release to 3.0

I've just written up a version which uses the ZipArchive class (Only available with the PHP Zip extension loaded).

When running locally on my system(extracting the wordpress 2.9.1 package via WP_Filesystem_Direct), the output of ZipArchive and PclZip appear to match exactly.

Both take approximately the same ammount of time locally.

ZipArchive uses on peak average, 2.25MB of memory. PclZip uses on peak average 11.70MB of memory (approximately the same size as the Compressed file & uncompressed files).

Code used for testing:

WP_Filesystem( array('hostname' => '', 'username' => '', 'password' => '') );

add_filter('unzip_file_use_ziparchive', 'return_true');
function return_false() { return false; } // Use PclZip
function return_true() { return true; } // Use ZipArchive


var_dump( memory_get_peak_usage(true) );

var_dump( unzip_file(ABSPATH . '', ABSPATH . 'test' . time()) )

timer_stop(1, 5);

var_dump( memory_get_peak_usage(true) );

#9 @dd32
14 years ago

(In [13005]) Introduce ZipArchive version of unzip_file(), More efficient on memory usage for supporting hosts. See #10403

#10 @dd32
14 years ago

(In [13006]) Better error checking for ZipArchive extraction. See #10403

#11 @dd32
14 years ago

(In [13007]) PHPdoc for _unzip_file_pclzip & _unzip_file_ziparchive. See #10403

#12 @westi
14 years ago

(In [13015]) Make _unzip_file_ziparchive() PHP4 safe. See #10403.

#13 @dd32
14 years ago

  • Resolution set to fixed
  • Status changed from accepted to closed

Closing a fixed. Open new tickets if any issues arrise from this.

Note: See TracTickets for help on using tickets.