diff --git a/src/Composer/Downloader/ZipDownloader.php b/src/Composer/Downloader/ZipDownloader.php index 06f33347c..5472ffe84 100644 --- a/src/Composer/Downloader/ZipDownloader.php +++ b/src/Composer/Downloader/ZipDownloader.php @@ -54,6 +54,12 @@ class ZipDownloader extends ArchiveDownloader } } + $procOpenMissing = false; + if (!function_exists('proc_open')) { + self::$unzipCommands = array(); + $procOpenMissing = true; + } + if (null === self::$hasZipArchive) { self::$hasZipArchive = class_exists('ZipArchive'); } @@ -61,7 +67,11 @@ class ZipDownloader extends ArchiveDownloader if (!self::$hasZipArchive && !self::$unzipCommands) { // 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/7z commands are both missing, skipping.\n" . $iniMessage; + if ($procOpenMissing) { + $error = "The zip extension is missing and unzip/7z commands cannot be called as proc_open is disabled, skipping.\n" . $iniMessage; + } else { + $error = "The zip extension and unzip/7z commands are both missing, skipping.\n" . $iniMessage; + } throw new \RuntimeException($error); } @@ -70,9 +80,15 @@ class ZipDownloader extends ArchiveDownloader self::$isWindows = Platform::isWindows(); if (!self::$isWindows && !self::$unzipCommands) { - $this->io->writeError("As there is no 'unzip' nor '7z' command installed zip files are being unpacked using the PHP zip extension."); - $this->io->writeError("This may cause invalid reports of corrupted archives. Besides, any UNIX permissions (e.g. executable) defined in the archives will be lost."); - $this->io->writeError("Installing 'unzip' or '7z' may remediate them."); + if ($procOpenMissing) { + $this->io->writeError("proc_open is disabled so 'unzip' and '7z' commands cannot be used, zip files are being unpacked using the PHP zip extension."); + $this->io->writeError("This may cause invalid reports of corrupted archives. Besides, any UNIX permissions (e.g. executable) defined in the archives will be lost."); + $this->io->writeError("Enabling proc_open and installing 'unzip' or '7z' may remediate them."); + } else { + $this->io->writeError("As there is no 'unzip' nor '7z' command installed zip files are being unpacked using the PHP zip extension."); + $this->io->writeError("This may cause invalid reports of corrupted archives. Besides, any UNIX permissions (e.g. executable) defined in the archives will be lost."); + $this->io->writeError("Installing 'unzip' or '7z' may remediate them."); + } } }