From 07867724d0b053a1b43241ee983143f5a5156d8b Mon Sep 17 00:00:00 2001 From: Rasmus Schultz Date: Fri, 1 Jun 2018 12:47:22 +0200 Subject: [PATCH 1/2] add back the warning about missing unzip display an error-message on non-Windows OS if unzip is unavailable, per #7383 --- src/Composer/Downloader/ZipDownloader.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Composer/Downloader/ZipDownloader.php b/src/Composer/Downloader/ZipDownloader.php index 00f7fbd1b..aeade031b 100644 --- a/src/Composer/Downloader/ZipDownloader.php +++ b/src/Composer/Downloader/ZipDownloader.php @@ -58,6 +58,11 @@ class ZipDownloader extends ArchiveDownloader if (null === self::$isWindows) { self::$isWindows = Platform::isWindows(); + + if (!self::$isWindows && !self::$hasSystemUnzip) { + $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."); + } } if (!self::$hasZipArchive && !self::$hasSystemUnzip) { From 5bae1913abfea7bdea9fc13c81f26403e36b3d68 Mon Sep 17 00:00:00 2001 From: Rasmus Schultz Date: Thu, 7 Jun 2018 11:08:50 +0200 Subject: [PATCH 2/2] swap tests to prevent conflicting error-messages --- src/Composer/Downloader/ZipDownloader.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Composer/Downloader/ZipDownloader.php b/src/Composer/Downloader/ZipDownloader.php index aeade031b..6217aaa53 100644 --- a/src/Composer/Downloader/ZipDownloader.php +++ b/src/Composer/Downloader/ZipDownloader.php @@ -56,6 +56,14 @@ class ZipDownloader extends ArchiveDownloader self::$hasZipArchive = class_exists('ZipArchive'); } + if (!self::$hasZipArchive && !self::$hasSystemUnzip) { + // php.ini path is added to the error message to help users find the correct file + $iniMessage = IniHelper::getMessage(); + $error = "The zip extension and unzip command are both missing, skipping.\n" . $iniMessage; + + throw new \RuntimeException($error); + } + if (null === self::$isWindows) { self::$isWindows = Platform::isWindows(); @@ -65,14 +73,6 @@ class ZipDownloader extends ArchiveDownloader } } - if (!self::$hasZipArchive && !self::$hasSystemUnzip) { - // php.ini path is added to the error message to help users find the correct file - $iniMessage = IniHelper::getMessage(); - $error = "The zip extension and unzip command are both missing, skipping.\n" . $iniMessage; - - throw new \RuntimeException($error); - } - return parent::download($package, $path, $output); }