1
0
Fork 0

PoolBuilder: Ensure alias references get removed when unfixing a locked package

Use the last key + 1 for an index instead of count, since we unset elements somtimes
pull/8717/head
Nils Adermann 2020-04-01 16:29:24 +02:00
parent c270d3cfa6
commit 14000e7575
2 changed files with 51 additions and 1 deletions

View File

@ -200,7 +200,8 @@ class PoolBuilder
private function loadPackage(Request $request, PackageInterface $package, $propagateUpdate = true)
{
$index = count($this->packages);
end($this->packages);
$index = key($this->packages) + 1;
$this->packages[] = $package;
if ($package instanceof AliasPackage) {
@ -348,6 +349,7 @@ class PoolBuilder
if ($loadedPackage->getName() === $name && $loadedPackage->getRepository() === $request->getLockedRepository()) {
$request->unfixPackage($loadedPackage);
unset($this->packages[$i]);
unset($this->aliasMap[spl_object_hash($loadedPackage)]);
}
}

View File

@ -0,0 +1,48 @@
--TEST--
Require a new package in the composer.json and updating with its name as an argument and with-dependencies should update locked dependencies as far as possible
--COMPOSER--
{
"repositories": [
{
"type": "package",
"package": [
{ "name": "current/pkg", "version": "1.0.0", "require": { "current/dep": "<1.2.0" } },
{ "name": "current/pkg", "version": "1.1.0", "require": { "current/dep": "^1.0" } },
{ "name": "current/dep", "version": "1.0.0" },
{ "name": "current/dep", "version": "1.1.0" },
{ "name": "current/dep", "version": "1.2.0" },
{ "name": "new/pkg", "version": "1.0.0", "require": { "current/dep": "^1.1" } },
{ "name": "new/pkg", "version": "1.1.0", "require": { "current/dep": "^1.2" } }
]
}
],
"require": {
"current/pkg": "1.*",
"new/pkg": "1.*"
}
}
--INSTALLED--
[
{ "name": "current/pkg", "version": "1.0.0", "require": { "current/dep": "<1.2.0" } },
{ "name": "current/dep", "version": "1.0.0" }
]
--LOCK--
{
"packages": [
{ "name": "current/pkg", "version": "1.0.0", "require": { "current/dep": "<1.2.0" } },
{ "name": "current/dep", "version": "1.0.0" }
],
"packages-dev": [],
"aliases": [],
"minimum-stability": "dev",
"stability-flags": [],
"prefer-stable": false,
"prefer-lowest": false,
"platform": [],
"platform-dev": []
}
--RUN--
update new/pkg --with-dependencies
--EXPECT--
Upgrading current/dep (1.0.0 => 1.1.0)
Installing new/pkg (1.0.0)