1
0
Fork 0

Fix handling of root aliases in partial updates, fixes #9110

pull/9152/head
Jordi Boggiano 2020-08-25 11:05:28 +02:00
parent 05e9fe936f
commit 6186c7f36f
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC
2 changed files with 82 additions and 1 deletions

View File

@ -390,8 +390,12 @@ class Installer
// if we're updating mirrors we want to keep exactly the same versions installed which are in the lock file, but we want current remote metadata
if ($this->updateMirrors && $lockedRepository) {
foreach ($lockedRepository->getPackages() as $lockedPackage) {
// exclude alias packages here as for root aliases, both alias and aliased are
// present in the lock repo and we only want to require the aliased version
if (!$lockedPackage instanceof AliasPackage) {
$request->requireName($lockedPackage->getName(), new Constraint('==', $lockedPackage->getVersion()));
}
}
} else {
$links = array_merge($this->package->getRequires(), $this->package->getDevRequires());
foreach ($links as $link) {

View File

@ -0,0 +1,77 @@
--TEST--
Partial update from lock file with root aliases should work
--COMPOSER--
{
"repositories": [
{
"type": "package",
"package": [
{ "name": "a/dep", "version": "1.0.0", "require": { "c/aliased": "2.0.0" } },
{ "name": "b/dep", "version": "1.0.0", "require": { "c/aliased": "1.0.0" } },
{ "name": "c/aliased", "version": "1.0.0" },
{ "name": "c/aliased", "version": "2.0.0" }
]
}
],
"require": {
"a/dep": "*",
"b/dep": "*",
"c/aliased": "1.0.0 as 2.0.0"
}
}
--LOCK--
{
"packages": [
{ "name": "a/dep", "version": "1.0.0", "require": { "c/aliased": "2.0.0" } },
{ "name": "b/dep", "version": "1.0.0", "require": { "c/aliased": "1.0.0" } },
{ "name": "c/aliased", "version": "1.0.0" }
],
"packages-dev": [],
"aliases": [
{
"package": "c/aliased",
"version": "1.0.0.0",
"alias": "2.0.0",
"alias_normalized": "2.0.0.0"
}
],
"minimum-stability": "stable",
"stability-flags": [],
"prefer-stable": false,
"prefer-lowest": false,
"platform": [],
"platform-dev": []
}
--INSTALLED--
[
{ "name": "a/dep", "version": "1.0.0", "require": { "c/aliased": "2.0.0" } },
{ "name": "b/dep", "version": "1.0.0", "require": { "c/aliased": "1.0.0" } },
{ "name": "c/aliased", "version": "1.0.0" }
]
--RUN--
update --lock
--EXPECT-LOCK--
{
"packages": [
{ "name": "a/dep", "version": "1.0.0", "require": { "c/aliased": "2.0.0" }, "type": "library" },
{ "name": "b/dep", "version": "1.0.0", "require": { "c/aliased": "1.0.0" }, "type": "library" },
{ "name": "c/aliased", "version": "1.0.0", "type": "library" }
],
"packages-dev": [],
"aliases": [
{
"package": "c/aliased",
"version": "1.0.0.0",
"alias": "2.0.0",
"alias_normalized": "2.0.0.0"
}
],
"minimum-stability": "stable",
"stability-flags": [],
"prefer-stable": false,
"prefer-lowest": false,
"platform": [],
"platform-dev": []
}
--EXPECT--
Marking c/aliased (2.0.0) as installed, alias of c/aliased (1.0.0)