From 90f8d01614758ebdc96672d6ceb5f68fbffb16aa Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Mon, 11 Sep 2023 17:45:19 +0200 Subject: [PATCH] Fix loading of root aliases on path repo packages when doing partial updates, fixes #11630 (#11632) --- .../DependencyResolver/PoolBuilder.php | 5 +- ...ate-loads-root-aliases-for-path-repos.test | 53 +++++++++++++++++++ 2 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 tests/Composer/Test/Fixtures/installer/partial-update-loads-root-aliases-for-path-repos.test diff --git a/src/Composer/DependencyResolver/PoolBuilder.php b/src/Composer/DependencyResolver/PoolBuilder.php index de7626fe4..b0ce25cc1 100644 --- a/src/Composer/DependencyResolver/PoolBuilder.php +++ b/src/Composer/DependencyResolver/PoolBuilder.php @@ -417,7 +417,10 @@ class PoolBuilder // if propagateUpdate is false we are loading a fixed or locked package, root aliases do not apply as they are // manually loaded as separate packages in this case - if ($propagateUpdate && isset($this->rootAliases[$name][$package->getVersion()])) { + // + // packages in pathRepoUnlocked however need to also load root aliases, they have propagateUpdate set to + // false because their deps should not be unlocked, but that is irrelevant for root aliases + if (($propagateUpdate || isset($this->pathRepoUnlocked[$package->getName()])) && isset($this->rootAliases[$name][$package->getVersion()])) { $alias = $this->rootAliases[$name][$package->getVersion()]; if ($package instanceof AliasPackage) { $basePackage = $package->getAliasOf(); diff --git a/tests/Composer/Test/Fixtures/installer/partial-update-loads-root-aliases-for-path-repos.test b/tests/Composer/Test/Fixtures/installer/partial-update-loads-root-aliases-for-path-repos.test new file mode 100644 index 000000000..71d961e09 --- /dev/null +++ b/tests/Composer/Test/Fixtures/installer/partial-update-loads-root-aliases-for-path-repos.test @@ -0,0 +1,53 @@ +--TEST-- +Partial updates always load root aliases even for path repos which are symlinked but not marked as updating + +--COMPOSER-- +{ + "repositories": [ + { + "type": "path", + "url": "Fixtures/functional/installed-versions/plugin-a" + }, + { + "type": "package", + "package": [ + { "name": "c/new", "version": "2.0.0", "require": { "plugin/a": "2.*" } } + ] + } + ], + "require": { + "plugin/a": "1.1.1 as 2.0.0", + "c/new": "*" + } +} + +--LOCK-- +{ + "packages": [ + { "name": "plugin/a", "version": "1.0.0", "dist": { "type": "path", "url": "..." }, "transport-options": {}, "require": { "symfony/console": "1.*" } }, + { "name": "symfony/console", "version": "1.0.0" } + ], + "packages-dev": [], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": { + }, + "prefer-stable": false, + "prefer-lowest": false, + "platform": [], + "platform-dev": [] +} + +--INSTALLED-- +[ + { "name": "plugin/a", "version": "1.1.1", "require": { "symfony/console": "2.0.*" } }, + { "name": "symfony/console", "version": "1.0.0" } +] + +--RUN-- +update c/new -v + +--EXPECT-- +Upgrading plugin/a (1.1.1 => 1.1.1 b133081) +Marking plugin/a (2.0.0) as installed, alias of plugin/a (1.1.1) +Installing c/new (2.0.0)