diff --git a/CHANGELOG.md b/CHANGELOG.md index b3ca99bb7..3547dc8a6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,12 @@ * Fixed symlink creation in linux VM guest filesystems to be recognized by Windows (#10592) * Performance improvement in pool optimization step (#10585) +### [2.2.10] 2022-03-29 + + * Fixed Bitbucket authorization detection due to API changes (#10657) + * Fixed validate command warning about dist/source keys if defined (#10655) + * Fixed deletion/handling of corrupted 0-bytes zip archives (#10666) + ### [2.2.9] 2022-03-15 * Fixed regression with plugins that modify install path of packages, [see docs](https://getcomposer.org/doc/articles/plugins.md#plugin-modifies-install-path) if you are authoring such a plugin (#10621) @@ -1437,6 +1443,7 @@ [2.3.0-RC2]: https://github.com/composer/composer/compare/2.3.0-RC1...2.3.0-RC2 [2.3.0-RC1]: https://github.com/composer/composer/compare/2.2.9...2.3.0-RC1 +[2.2.10]: https://github.com/composer/composer/compare/2.2.9...2.2.10 [2.2.9]: https://github.com/composer/composer/compare/2.2.8...2.2.9 [2.2.8]: https://github.com/composer/composer/compare/2.2.7...2.2.8 [2.2.7]: https://github.com/composer/composer/compare/2.2.6...2.2.7 diff --git a/src/Composer/Downloader/ZipDownloader.php b/src/Composer/Downloader/ZipDownloader.php index 1feec5b4d..93ee29162 100644 --- a/src/Composer/Downloader/ZipDownloader.php +++ b/src/Composer/Downloader/ZipDownloader.php @@ -13,6 +13,7 @@ namespace Composer\Downloader; use Composer\Package\PackageInterface; +use Composer\Pcre\Preg; use Composer\Util\IniHelper; use Composer\Util\Platform; use Composer\Util\ProcessExecutor; @@ -87,11 +88,11 @@ class ZipDownloader extends ArchiveDownloader 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."); + $this->io->writeError("Enabling proc_open and installing 'unzip' or '7z' (21.01+) 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."); + $this->io->writeError("Installing 'unzip' or '7z' (21.01+) may remediate them."); } } } @@ -108,6 +109,8 @@ class ZipDownloader extends ArchiveDownloader */ private function extractWithSystemUnzip(PackageInterface $package, string $file, string $path): PromiseInterface { + static $warned7ZipLinux = false; + // Force Exception throwing if the other alternative extraction method is not available $isLastChance = !self::$hasZipArchive; @@ -126,6 +129,14 @@ class ZipDownloader extends ArchiveDownloader } $executable = $commandSpec[0]; + if (!$warned7ZipLinux && !Platform::isWindows() && in_array($executable, array('7z', '7zz'), true)) { + $warned7ZipLinux = true; + if (0 === $this->process->execute($executable, $output)) { + if (Preg::isMatch('{^\s*7-Zip(?: \[64\])? ([0-9.]+)}', $output, $match) && version_compare($match[1], '21.01', '<')) { + $this->io->writeError(' Unzipping using '.$executable.' '.$match[1].' may result in incorrect file permissions. Install '.$executable.' 21.01+ or unzip to ensure you get correct permissions.'); + } + } + } $io = $this->io; $tryFallback = function (\Throwable $processError) use ($isLastChance, $io, $file, $path, $package, $executable): \React\Promise\PromiseInterface { diff --git a/tests/Composer/Test/Fixtures/functional/installed-versions.test b/tests/Composer/Test/Fixtures/functional/installed-versions.test index 57e34bf83..47c31bf3f 100644 --- a/tests/Composer/Test/Fixtures/functional/installed-versions.test +++ b/tests/Composer/Test/Fixtures/functional/installed-versions.test @@ -21,7 +21,7 @@ Lock file operations: 6 installs, 0 updates, 0 removals - Locking symfony/process (12345.1.2) Writing lock file Installing dependencies from lock file (including require-dev) -Package operations: 6 installs, 0 updates, 0 removals%(\nAs there is no 'unzip' nor '7z' command installed zip files are being unpacked using the PHP zip extension.\nThis may cause invalid reports of corrupted archives. Besides, any UNIX permissions \(e.g. executable\) defined in the archives will be lost.\nInstalling 'unzip' or '7z' may remediate them.)?% +Package operations: 6 installs, 0 updates, 0 removals%(\nAs there is no 'unzip' nor '7z' command installed zip files are being unpacked using the PHP zip extension.\nThis may cause invalid reports of corrupted archives. Besides, any UNIX permissions \(e.g. executable\) defined in the archives will be lost.\nInstalling 'unzip' or '7z' \(21\.01\+\) may remediate them.)?% - Downloading symfony/polyfill-ctype (%v?[1-8]\.\d+\.\d+%) - Downloading symfony/filesystem (%v?[2-8]\.\d+\.\d+%) - Installing symfony/console (99999.1.2): Symlinking from symfony-console diff --git a/tests/Composer/Test/Fixtures/functional/installed-versions2.test b/tests/Composer/Test/Fixtures/functional/installed-versions2.test index ce6aa9d7b..c119c43ff 100644 --- a/tests/Composer/Test/Fixtures/functional/installed-versions2.test +++ b/tests/Composer/Test/Fixtures/functional/installed-versions2.test @@ -26,7 +26,7 @@ Lock file operations: 0 installs, 5 updates, 0 removals - Upgrading symfony/process (12345.1.2 => 12345.1.3) Writing lock file Installing dependencies from lock file (including require-dev) -Package operations: 0 installs, 5 updates, 0 removals%(\nAs there is no 'unzip' nor '7z' command installed zip files are being unpacked using the PHP zip extension.\nThis may cause invalid reports of corrupted archives. Besides, any UNIX permissions \(e.g. executable\) defined in the archives will be lost.\nInstalling 'unzip' or '7z' may remediate them.)?% +Package operations: 0 installs, 5 updates, 0 removals%(\nAs there is no 'unzip' nor '7z' command installed zip files are being unpacked using the PHP zip extension.\nThis may cause invalid reports of corrupted archives. Besides, any UNIX permissions \(e.g. executable\) defined in the archives will be lost.\nInstalling 'unzip' or '7z' \(21\.01\+\) may remediate them.)?% - Downloading symfony/filesystem (%v?[2-8]\.\d+\.\d+%) - Upgrading symfony/console (99999.1.2 => 99999.1.3): Mirroring from symfony-console - Upgrading plugin/a (1.1.1 => 1.1.2): Mirroring from plugin-a