1
0
Fork 0

Prioritize repository over package versions in the default policy, fixes #3509

pull/3982/head
Jordi Boggiano 2015-04-30 10:38:42 +01:00
parent 00ca2a91a3
commit d6620195e5
3 changed files with 39 additions and 9 deletions

View File

@ -12,6 +12,13 @@ resulting order in which the solver will try to install them.
The rules are to be applied in the order of these descriptions. The rules are to be applied in the order of these descriptions.
### Repository priorities
Packages Repo1.Av1, Repo2.Av1
* priority(Repo1) >= priority(Repo2) => (Repo1.Av1, Repo2.Av1)
* priority(Repo1) < priority(Repo2) => (Repo2.Av1, Repo1.Av1)
### Package versions ### Package versions
Packages: Av1, Av2, Av3 Packages: Av1, Av2, Av3
@ -22,13 +29,6 @@ Request: install A
* (Av3) * (Av3)
### Repository priorities
Packages Repo1.Av1, Repo2.Av1
* priority(Repo1) >= priority(Repo2) => (Repo1.Av1, Repo2.Av1)
* priority(Repo1) < priority(Repo2) => (Repo2.Av1, Repo1.Av1)
### Virtual Packages (provides) ### Virtual Packages (provides)
Packages Av1, Bv1 Packages Av1, Bv1

View File

@ -82,10 +82,10 @@ class DefaultPolicy implements PolicyInterface
} }
foreach ($packages as &$literals) { foreach ($packages as &$literals) {
$literals = $this->pruneToBestVersion($pool, $literals);
$literals = $this->pruneToHighestPriorityOrInstalled($pool, $installedMap, $literals); $literals = $this->pruneToHighestPriorityOrInstalled($pool, $installedMap, $literals);
$literals = $this->pruneToBestVersion($pool, $literals);
$literals = $this->pruneRemoteAliases($pool, $literals); $literals = $this->pruneRemoteAliases($pool, $literals);
} }

View File

@ -0,0 +1,30 @@
--TEST--
Install prefers higher priority repositories over higher priority package versions
--COMPOSER--
{
"repositories": [
{
"type": "package",
"package": [
{ "name": "a/a", "version": "1.0.0" }
]
},
{
"type": "package",
"package": [
{ "name": "a/a", "version": "1.1.0" },
{ "name": "b/b", "version": "1.1.0" },
{ "name": "b/b", "version": "1.0.0" }
]
}
],
"require": {
"a/a": "*",
"b/b": "*"
}
}
--RUN--
install
--EXPECT--
Installing a/a (1.0.0)
Installing b/b (1.1.0)