From 379d7691326304b91c250faabbf252f9e257c12f Mon Sep 17 00:00:00 2001 From: Niels Keurentjes Date: Fri, 26 Feb 2016 08:38:39 +0100 Subject: [PATCH 1/2] Troubleshooting and warning in code related to issues with native ZipArchiver. --- doc/articles/troubleshooting.md | 11 +++++++++++ src/Composer/Downloader/ZipDownloader.php | 5 ++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/doc/articles/troubleshooting.md b/doc/articles/troubleshooting.md index ad46d7114..9582fd500 100644 --- a/doc/articles/troubleshooting.md +++ b/doc/articles/troubleshooting.md @@ -345,3 +345,14 @@ composer update ``` See also https://github.com/composer/composer/issues/4180 for more information. + +## Zip archives are being reported as corrupted or not unpacked correctly. + +Composer can unpack zipballs using either a system-provided `unzip` utility or PHP's +native `ZipArchiver` class, preferring the first. The `ZipArchiver` class however is +known to occassionally report valid zip files as corrupted, and does not support certain +advanced features with permissions and symlinks. + +If you have issues with zip files you should install a native implementation of unzip +and verify whether the problem persists. If so it is likely a real issue in the file +itself and you should contact the provider. diff --git a/src/Composer/Downloader/ZipDownloader.php b/src/Composer/Downloader/ZipDownloader.php index aaa45200b..5b29b1493 100644 --- a/src/Composer/Downloader/ZipDownloader.php +++ b/src/Composer/Downloader/ZipDownloader.php @@ -98,7 +98,10 @@ class ZipDownloader extends ArchiveDownloader } if (true !== $zipArchive->extractTo($path)) { - throw new \RuntimeException("There was an error extracting the ZIP file. Corrupt file?"); + $this->io->writeError("As there is no 'unzip' command installed zip files are being unpacked using the PHP zip extension."); + $this->io->writeError(" This may cause invalid reports of corrupted archives. Installing 'unzip' may remediate them."); + + throw new \RuntimeException("There was an error extracting the ZIP file, it is either corrupted or using an invalid format"); } $zipArchive->close(); From d60e0c1842d37be25cd31658a54da127158573d2 Mon Sep 17 00:00:00 2001 From: Niels Keurentjes Date: Fri, 26 Feb 2016 14:45:19 +0100 Subject: [PATCH 2/2] Accidentally indented. --- src/Composer/Downloader/ZipDownloader.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Composer/Downloader/ZipDownloader.php b/src/Composer/Downloader/ZipDownloader.php index 5b29b1493..5278be91b 100644 --- a/src/Composer/Downloader/ZipDownloader.php +++ b/src/Composer/Downloader/ZipDownloader.php @@ -99,7 +99,7 @@ class ZipDownloader extends ArchiveDownloader if (true !== $zipArchive->extractTo($path)) { $this->io->writeError("As there is no 'unzip' command installed zip files are being unpacked using the PHP zip extension."); - $this->io->writeError(" This may cause invalid reports of corrupted archives. Installing 'unzip' may remediate them."); + $this->io->writeError("This may cause invalid reports of corrupted archives. Installing 'unzip' may remediate them."); throw new \RuntimeException("There was an error extracting the ZIP file, it is either corrupted or using an invalid format"); }