MDL-70631 files: Fix performance of zip_packer::extract_to_pathname()
commitb227b6ea455955dfdb0266e00208ef3cb03c7d0b
authorDavid Mudrák <david@moodle.com>
Thu, 14 Jan 2021 20:33:44 +0000 (14 21:33 +0100)
committerDavid Mudrák <david@moodle.com>
Wed, 3 Feb 2021 15:06:39 +0000 (3 16:06 +0100)
tree81841c0b7ec78871d11013f041d1d46ab18cdaa5
parent9dabd071fe7c09ba10f0a7a7b7c7d8164bca9c95
MDL-70631 files: Fix performance of zip_packer::extract_to_pathname()

The original implementation was based on ZipArchive::getStream() which
turns out to be very slow and if the archive contains many files, the
unzipping performance is very slow.

The patch changes the implementation to use ZipArchive::extractTo()
unless the extracted entry path contains a folder name ending with dot
(such as some/path./to/file.txt). There is a known upstream bug in the
PHP ZIP extension #77214 (also #74619 and #69477) so that we fall back
to keep using the stream in those cases.
lib/filestorage/tests/zip_packer_test.php
lib/filestorage/zip_archive.php
lib/filestorage/zip_packer.php