From b639005f2975378b72dc915b857b84f36a2985df Mon Sep 17 00:00:00 2001 From: Christophe Coevoet Date: Fri, 21 Feb 2014 16:26:53 +0100 Subject: [PATCH 1/3] Added a failing test for #2626 --- .../Fixtures/installer/replace-alias.test | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 tests/Composer/Test/Fixtures/installer/replace-alias.test diff --git a/tests/Composer/Test/Fixtures/installer/replace-alias.test b/tests/Composer/Test/Fixtures/installer/replace-alias.test new file mode 100644 index 000000000..c3660cd6b --- /dev/null +++ b/tests/Composer/Test/Fixtures/installer/replace-alias.test @@ -0,0 +1,24 @@ +--TEST-- +Ensure a replacer package deals with branch aliases +--COMPOSER-- +{ + "repositories": [ + { + "type": "package", + "package": [ + { "name": "a/a", "version": "dev-master", "replace": {"c/c": "self.version" }, "extra": { "branch-alias": {"dev-master": "1.0.x-dev"} } }, + { "name": "b/b", "version": "1.0.0", "require": {"c/c": "1.*"} }, + { "name": "c/c", "version": "dev-master", "extra": { "branch-alias": {"dev-master": "1.0.x-dev"} } } + ] + } + ], + "require": { + "a/a": "dev-master", + "b/b": "1.*" + } +} +--RUN-- +install +--EXPECT-- +Installing a/a (dev-master) +Installing b/b (1.0.0) From 224132893490f57e9aa6f9b7c89f8e9de70f6372 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Wed, 12 Mar 2014 15:12:34 +0100 Subject: [PATCH 2/3] fix "replace-alias.test" test --- tests/Composer/Test/Fixtures/installer/replace-alias.test | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/Composer/Test/Fixtures/installer/replace-alias.test b/tests/Composer/Test/Fixtures/installer/replace-alias.test index c3660cd6b..327fb5ab5 100644 --- a/tests/Composer/Test/Fixtures/installer/replace-alias.test +++ b/tests/Composer/Test/Fixtures/installer/replace-alias.test @@ -21,4 +21,5 @@ Ensure a replacer package deals with branch aliases install --EXPECT-- Installing a/a (dev-master) +Marking a/a (1.0.x-dev) as installed, alias of a/a (dev-master) Installing b/b (1.0.0) From 0e9325da796a5a3b990a2d756ea5e5a2376841bd Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Wed, 12 Mar 2014 16:30:09 +0100 Subject: [PATCH 3/3] for AliasPackages check that the aliased package is white listed so that version constraints of AliasPackages are taken into account when computing package provisions --- src/Composer/DependencyResolver/Pool.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Composer/DependencyResolver/Pool.php b/src/Composer/DependencyResolver/Pool.php index 18f2d5797..853673905 100644 --- a/src/Composer/DependencyResolver/Pool.php +++ b/src/Composer/DependencyResolver/Pool.php @@ -268,9 +268,18 @@ class Pool $nameMatch = false; foreach ($candidates as $candidate) { + $aliasOfCandidate = null; + + // alias packages are not white listed, make sure that the package + // being aliased is white listed + if ($candidate instanceof AliasPackage) { + $aliasOfCandidate = $candidate->getAliasOf(); + } + if ($this->whitelist !== null && ( (is_array($candidate) && isset($candidate['id']) && !isset($this->whitelist[$candidate['id']])) || - (is_object($candidate) && !isset($this->whitelist[$candidate->getId()])) + (is_object($candidate) && !($candidate instanceof AliasPackage) && !isset($this->whitelist[$candidate->getId()])) || + (is_object($candidate) && $candidate instanceof AliasPackage && !isset($this->whitelist[$aliasOfCandidate->getId()])) )) { continue; }