From 30671fb9040a06d2369ade29e8fcae3b380c9b8e Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Tue, 29 Mar 2022 20:36:39 +0200 Subject: [PATCH 1/6] Add warning when using 7z <21.01 on linux/osx, fixes #10535 --- src/Composer/Downloader/ZipDownloader.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/Composer/Downloader/ZipDownloader.php b/src/Composer/Downloader/ZipDownloader.php index fe1bfdc69..05f2db6bb 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; @@ -86,11 +87,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."); } } } @@ -107,6 +108,8 @@ class ZipDownloader extends ArchiveDownloader */ private function extractWithSystemUnzip(PackageInterface $package, $file, $path) { + static $warned7ZipLinux = false; + // Force Exception throwing if the other alternative extraction method is not available $isLastChance = !self::$hasZipArchive; @@ -125,6 +128,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.'); + } + } + } $self = $this; $io = $this->io; From 60616f9bd1797e85b87dd4fd63a6f27c1f0b8bf9 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Tue, 29 Mar 2022 21:27:43 +0200 Subject: [PATCH 2/6] Fix tests --- tests/Composer/Test/Fixtures/functional/installed-versions.test | 2 +- .../Composer/Test/Fixtures/functional/installed-versions2.test | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Composer/Test/Fixtures/functional/installed-versions.test b/tests/Composer/Test/Fixtures/functional/installed-versions.test index 42bc212fd..e1a2718f1 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 2d7ef199d..4e80df7c2 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 From 7eb8f92a937161288153e55a56304d3754e2acc4 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Tue, 29 Mar 2022 21:37:41 +0200 Subject: [PATCH 3/6] Fix test --- .../Composer/Test/Fixtures/functional/installed-versions2.test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Composer/Test/Fixtures/functional/installed-versions2.test b/tests/Composer/Test/Fixtures/functional/installed-versions2.test index 4e80df7c2..fa83bf79b 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' \(21\.01\+\) 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 From 1240bdadcf313722de46cdbe85a808f6f3434ff1 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Tue, 29 Mar 2022 21:38:32 +0200 Subject: [PATCH 4/6] Update changelog --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 868375d45..5334282f8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +### [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) @@ -1406,6 +1412,7 @@ * Initial release +[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 From 18f748df692b6304b5baf077786c003c48e7f990 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Tue, 29 Mar 2022 21:55:36 +0200 Subject: [PATCH 5/6] Release 2.2.10 --- src/Composer/Composer.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Composer/Composer.php b/src/Composer/Composer.php index 624e02507..c2bd6d32f 100644 --- a/src/Composer/Composer.php +++ b/src/Composer/Composer.php @@ -52,10 +52,10 @@ class Composer * const RELEASE_DATE = '@release_date@'; * const SOURCE_VERSION = '1.8-dev+source'; */ - const VERSION = '@package_version@'; - const BRANCH_ALIAS_VERSION = '@package_branch_alias_version@'; - const RELEASE_DATE = '@release_date@'; - const SOURCE_VERSION = '2.2.999-dev+source'; + const VERSION = '2.2.10'; + const BRANCH_ALIAS_VERSION = ''; + const RELEASE_DATE = '2022-03-29 21:55:35'; + const SOURCE_VERSION = ''; /** * Version number of the internal composer-runtime-api package From 9c2793382badc36f6e3cf933713a9e2e2dd89603 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Tue, 29 Mar 2022 21:55:36 +0200 Subject: [PATCH 6/6] Reverting release version changes --- src/Composer/Composer.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Composer/Composer.php b/src/Composer/Composer.php index c2bd6d32f..624e02507 100644 --- a/src/Composer/Composer.php +++ b/src/Composer/Composer.php @@ -52,10 +52,10 @@ class Composer * const RELEASE_DATE = '@release_date@'; * const SOURCE_VERSION = '1.8-dev+source'; */ - const VERSION = '2.2.10'; - const BRANCH_ALIAS_VERSION = ''; - const RELEASE_DATE = '2022-03-29 21:55:35'; - const SOURCE_VERSION = ''; + const VERSION = '@package_version@'; + const BRANCH_ALIAS_VERSION = '@package_branch_alias_version@'; + const RELEASE_DATE = '@release_date@'; + const SOURCE_VERSION = '2.2.999-dev+source'; /** * Version number of the internal composer-runtime-api package