From d519fb8a5355405f338c2efa27bad64644906643 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Thu, 8 Apr 2021 10:40:55 +0200 Subject: [PATCH 1/3] Add warning when loading plugins of type composer-installer as they are unlikely to function correctly and should be upgraded to the composer-plugin type --- src/Composer/Plugin/PluginManager.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Composer/Plugin/PluginManager.php b/src/Composer/Plugin/PluginManager.php index aa9aec082..df62b620d 100644 --- a/src/Composer/Plugin/PluginManager.php +++ b/src/Composer/Plugin/PluginManager.php @@ -224,6 +224,7 @@ class PluginManager } if ($oldInstallerPlugin) { + $this->io->writeError('Loading "'.$package->getName() . '" '.($isGlobalPlugin ? '(installed globally) ' : '').'which is a legacy composer-installer built for Composer 1.x, it is likely to cause issues as you are running Composer 2.x.'); $installer = new $class($this->io, $this->composer); $this->composer->getInstallationManager()->addInstaller($installer); $this->registeredPlugins[$package->getName()] = $installer; From 0ab4013788b4795b618f0fe7fddd06bf65b862d7 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Thu, 8 Apr 2021 10:55:48 +0200 Subject: [PATCH 2/3] Fix output listing some updates that do not really happen when updating mirrors/--lock, fixes #9812 --- src/Composer/Installer.php | 9 +++++++++ .../installer/update-mirrors-changes-url.test | 17 +++++++++++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/Composer/Installer.php b/src/Composer/Installer.php index 1a7c5e694..e856aeb39 100644 --- a/src/Composer/Installer.php +++ b/src/Composer/Installer.php @@ -446,6 +446,15 @@ class Installer $installsUpdates[] = $operation; $installNames[] = $operation->getPackage()->getPrettyName().':'.$operation->getPackage()->getFullPrettyVersion(); } elseif ($operation instanceof UpdateOperation) { + // when mirrors/metadata from a package gets updated we do not want to list it as an + // update in the output as it is only an internal lock file metadata update + if ($this->updateMirrors + && $operation->getInitialPackage()->getName() == $operation->getTargetPackage()->getName() + && $operation->getInitialPackage()->getVersion() == $operation->getTargetPackage()->getVersion() + ) { + continue; + } + $installsUpdates[] = $operation; $updateNames[] = $operation->getTargetPackage()->getPrettyName().':'.$operation->getTargetPackage()->getFullPrettyVersion(); } elseif ($operation instanceof UninstallOperation) { diff --git a/tests/Composer/Test/Fixtures/installer/update-mirrors-changes-url.test b/tests/Composer/Test/Fixtures/installer/update-mirrors-changes-url.test index 554783fc0..767b6dbc5 100644 --- a/tests/Composer/Test/Fixtures/installer/update-mirrors-changes-url.test +++ b/tests/Composer/Test/Fixtures/installer/update-mirrors-changes-url.test @@ -17,7 +17,8 @@ g/g is dev and installed in a different ref than the #ref, so it gets updated an { "name": "a/a", "version": "dev-master", "source": { "reference": "2222222222222222222222222222222222222222", "url": "https://github.com/a/newa", "type": "git" }, - "dist": { "reference": "2222222222222222222222222222222222222222", "url": "https://api.github.com/repos/a/newa/zipball/2222222222222222222222222222222222222222", "type": "zip" } + "dist": { "reference": "2222222222222222222222222222222222222222", "url": "https://api.github.com/repos/a/newa/zipball/2222222222222222222222222222222222222222", "type": "zip" }, + "time": "2021-03-27T14:32:16+00:00" }, { "name": "b/b", "version": "2.0.3", @@ -67,7 +68,8 @@ g/g is dev and installed in a different ref than the #ref, so it gets updated an { "name": "a/a", "version": "dev-master", "source": { "reference": "1111111111111111111111111111111111111111", "url": "https://github.com/a/a", "type": "git" }, - "dist": { "reference": "1111111111111111111111111111111111111111", "url": "https://api.github.com/repos/a/a/zipball/1111111111111111111111111111111111111111", "type": "zip" } + "dist": { "reference": "1111111111111111111111111111111111111111", "url": "https://api.github.com/repos/a/a/zipball/1111111111111111111111111111111111111111", "type": "zip" }, + "time": "2021-03-14T16:24:37+00:00" }, { "name": "b/b", "version": "2.0.3", @@ -102,6 +104,7 @@ g/g is dev and installed in a different ref than the #ref, so it gets updated an "name": "a/a", "version": "dev-master", "source": { "reference": "1111111111111111111111111111111111111111", "url": "https://github.com/a/a", "type": "git" }, "dist": { "reference": "1111111111111111111111111111111111111111", "url": "https://api.github.com/repos/a/a/zipball/1111111111111111111111111111111111111111", "type": "zip" }, + "time": "2021-03-14T16:24:37+00:00", "type": "library" }, { @@ -151,6 +154,7 @@ g/g is dev and installed in a different ref than the #ref, so it gets updated an "name": "a/a", "version": "dev-master", "source": { "reference": "1111111111111111111111111111111111111111", "url": "https://github.com/a/newa", "type": "git" }, "dist": { "reference": "1111111111111111111111111111111111111111", "url": "https://api.github.com/repos/a/newa/zipball/1111111111111111111111111111111111111111", "type": "zip" }, + "time": "2021-03-27T14:32:16+00:00", "type": "library" }, { @@ -202,3 +206,12 @@ g/g is dev and installed in a different ref than the #ref, so it gets updated an --RUN-- update mirrors --EXPECT-- + +--EXPECT-OUTPUT-- +Loading composer repositories with package information +Updating dependencies +Lock file operations: 0 installs, 0 updates, 0 removals +Writing lock file +Installing dependencies from lock file (including require-dev) +Nothing to install, update or remove +Generating autoload files From e6cede4a6142d7df38282395e112ffa590270db1 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Thu, 8 Apr 2021 11:54:39 +0200 Subject: [PATCH 3/3] Make sure update mirrors/--lock keeps the release date of the original reference when dev versions have newer commits, refs #9812 --- src/Composer/DependencyResolver/LockTransaction.php | 13 +++++++------ .../installer/update-mirrors-changes-url.test | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/Composer/DependencyResolver/LockTransaction.php b/src/Composer/DependencyResolver/LockTransaction.php index f4f6d1bb8..eb5dead6b 100644 --- a/src/Composer/DependencyResolver/LockTransaction.php +++ b/src/Composer/DependencyResolver/LockTransaction.php @@ -93,12 +93,13 @@ class LockTransaction extends Transaction // we do not reset references if the currently present package didn't have any, or if the type of VCS has changed if ($updateMirrors && !isset($this->presentMap[spl_object_hash($package)])) { foreach ($this->presentMap as $presentPackage) { - if ($package->getName() == $presentPackage->getName() && - $package->getVersion() == $presentPackage->getVersion() && - $presentPackage->getSourceReference() && - $presentPackage->getSourceType() === $package->getSourceType() - ) { - $package->setSourceDistReferences($presentPackage->getSourceReference()); + if ($package->getName() == $presentPackage->getName() && $package->getVersion() == $presentPackage->getVersion()) { + if ($presentPackage->getSourceReference() && $presentPackage->getSourceType() === $package->getSourceType()) { + $package->setSourceDistReferences($presentPackage->getSourceReference()); + } + if ($presentPackage->getReleaseDate()) { + $package->setReleaseDate($presentPackage->getReleaseDate()); + } } } } diff --git a/tests/Composer/Test/Fixtures/installer/update-mirrors-changes-url.test b/tests/Composer/Test/Fixtures/installer/update-mirrors-changes-url.test index 767b6dbc5..edb821f8c 100644 --- a/tests/Composer/Test/Fixtures/installer/update-mirrors-changes-url.test +++ b/tests/Composer/Test/Fixtures/installer/update-mirrors-changes-url.test @@ -154,7 +154,7 @@ g/g is dev and installed in a different ref than the #ref, so it gets updated an "name": "a/a", "version": "dev-master", "source": { "reference": "1111111111111111111111111111111111111111", "url": "https://github.com/a/newa", "type": "git" }, "dist": { "reference": "1111111111111111111111111111111111111111", "url": "https://api.github.com/repos/a/newa/zipball/1111111111111111111111111111111111111111", "type": "zip" }, - "time": "2021-03-27T14:32:16+00:00", + "time": "2021-03-14T16:24:37+00:00", "type": "library" }, {