From ad7bc1802810b3236997e36d39600fc271b9f20f Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Fri, 27 Jan 2023 16:54:45 +0100 Subject: [PATCH] Fix self.version requirements failing the lock file integrity check if on a different version, fixes #11274 (#11283) --- src/Composer/Package/Locker.php | 3 +++ ...oot-requirements-do-not-affect-locked-versions.test | 10 +++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/Composer/Package/Locker.php b/src/Composer/Package/Locker.php index b46a798bd..c58947014 100644 --- a/src/Composer/Package/Locker.php +++ b/src/Composer/Package/Locker.php @@ -518,6 +518,9 @@ class Locker if (PlatformRepository::isPlatformPackage($link->getTarget())) { continue; } + if ($link->getPrettyConstraint() === 'self.version') { + continue; + } if ($installedRepo->findPackagesWithReplacersAndProviders($link->getTarget(), $link->getConstraint()) === []) { $results = $installedRepo->findPackagesWithReplacersAndProviders($link->getTarget()); if ($results !== []) { diff --git a/tests/Composer/Test/Fixtures/installer/root-requirements-do-not-affect-locked-versions.test b/tests/Composer/Test/Fixtures/installer/root-requirements-do-not-affect-locked-versions.test index 2b05f49e1..f8db5ff03 100644 --- a/tests/Composer/Test/Fixtures/installer/root-requirements-do-not-affect-locked-versions.test +++ b/tests/Composer/Test/Fixtures/installer/root-requirements-do-not-affect-locked-versions.test @@ -2,26 +2,30 @@ The locked version will not get overwritten by an install but fails on invalid packages --COMPOSER-- { + "version": "1.2.3", "repositories": [ { "type": "package", "package": [ { "name": "foo/bar", "version": "1.0.0" }, { "name": "foo/baz", "version": "1.0.0" }, - { "name": "foo/baz", "version": "2.0.0" } + { "name": "foo/baz", "version": "2.0.0" }, + { "name": "foo/self", "version": "1.2.3" } ] } ], "require": { "foo/bar": "2.0.0", - "foo/baz": "2.0.0" + "foo/baz": "2.0.0", + "foo/self": "self.version" } } --LOCK-- { "packages": [ { "name": "foo/bar", "version": "1.0.0" }, - { "name": "foo/baz", "version": "2.0.0" } + { "name": "foo/baz", "version": "2.0.0" }, + { "name": "foo/self", "version": "1.2.2" } ], "packages-dev": [], "aliases": [],