瀏覽代碼

Merge pull request #2805 from xabbuh/issue-2626

Check the referenced package for a white list entry
Nils Adermann 11 年之前
父節點
當前提交
70a20ebcc1
共有 2 個文件被更改,包括 35 次插入1 次删除
  1. 10 1
      src/Composer/DependencyResolver/Pool.php
  2. 25 0
      tests/Composer/Test/Fixtures/installer/replace-alias.test

+ 10 - 1
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;
             }

+ 25 - 0
tests/Composer/Test/Fixtures/installer/replace-alias.test

@@ -0,0 +1,25 @@
+--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)
+Marking a/a (1.0.x-dev) as installed, alias of a/a (dev-master)
+Installing b/b (1.0.0)