fix: If a replacer is updated to a version that no longer replaces, the replaced package is not loaded
parent
11879ea737
commit
010bad5428
|
@ -639,6 +639,8 @@ class PoolBuilder
|
||||||
// make sure that any requirements for this package by other locked or fixed packages are now
|
// make sure that any requirements for this package by other locked or fixed packages are now
|
||||||
// also loaded, as they were previously ignored because the locked (now unlocked) package already
|
// also loaded, as they were previously ignored because the locked (now unlocked) package already
|
||||||
// satisfied their requirements
|
// satisfied their requirements
|
||||||
|
// and if this package is replacing another that is required by a locked or fixed package, ensure
|
||||||
|
// that we load that replaced package in case an update to this package removes the replacement
|
||||||
foreach ($request->getFixedOrLockedPackages() as $fixedOrLockedPackage) {
|
foreach ($request->getFixedOrLockedPackages() as $fixedOrLockedPackage) {
|
||||||
if ($fixedOrLockedPackage === $lockedPackage) {
|
if ($fixedOrLockedPackage === $lockedPackage) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -649,6 +651,12 @@ class PoolBuilder
|
||||||
if (isset($requires[$lockedPackage->getName()])) {
|
if (isset($requires[$lockedPackage->getName()])) {
|
||||||
$this->markPackageNameForLoading($request, $lockedPackage->getName(), $requires[$lockedPackage->getName()]->getConstraint());
|
$this->markPackageNameForLoading($request, $lockedPackage->getName(), $requires[$lockedPackage->getName()]->getConstraint());
|
||||||
}
|
}
|
||||||
|
foreach ($lockedPackage->getReplaces() as $replace) {
|
||||||
|
if (isset($requires[$replace->getTarget()], $this->skippedLoad[$replace->getTarget()])) {
|
||||||
|
$this->unlockPackage($request, $repositories, $replace->getTarget());
|
||||||
|
$this->markPackageNameForLoading($request, $replace->getTarget(), $requires[$replace->getTarget()]->getConstraint());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,50 @@
|
||||||
|
--TEST--
|
||||||
|
Ensure that a package gets loaded which was previously skipped due to replacement
|
||||||
|
|
||||||
|
--REQUEST--
|
||||||
|
{
|
||||||
|
"require": {
|
||||||
|
"root/dep": "*",
|
||||||
|
"root/no-update": "*"
|
||||||
|
},
|
||||||
|
"locked": [
|
||||||
|
{"name": "root/dep", "version": "1.1.0", "require": {"replacer/pkg": "1.*"}},
|
||||||
|
{"name": "replacer/pkg", "version": "1.0.0", "replace": {"replaced/pkg": "1.0.0"}},
|
||||||
|
{"name": "root/no-update", "version": "1.0.0", "require": {"replaced/pkg": "1.0.0"}}
|
||||||
|
],
|
||||||
|
"allowList": [
|
||||||
|
"root/dep"
|
||||||
|
],
|
||||||
|
"allowTransitiveDepsNoRootRequire": true
|
||||||
|
}
|
||||||
|
|
||||||
|
--FIXED--
|
||||||
|
[
|
||||||
|
]
|
||||||
|
|
||||||
|
--PACKAGE-REPOS--
|
||||||
|
[
|
||||||
|
[
|
||||||
|
{"name": "root/dep", "version": "1.2.0", "require": {"replacer/pkg": ">=1.1.0"}},
|
||||||
|
{"name": "replacer/pkg", "version": "1.0.0", "replace": {"replaced/pkg": "1.0.0"}},
|
||||||
|
{"name": "replacer/pkg", "version": "1.1.0"},
|
||||||
|
{"name": "replaced/pkg", "version": "1.0.0"},
|
||||||
|
{"name": "root/no-update", "version": "1.0.0", "require": {"replaced/pkg": "1.0.0"}}
|
||||||
|
]
|
||||||
|
]
|
||||||
|
|
||||||
|
--EXPECT--
|
||||||
|
[
|
||||||
|
"root/no-update-1.0.0.0 (locked)",
|
||||||
|
"root/dep-1.2.0.0",
|
||||||
|
"replaced/pkg-1.0.0.0",
|
||||||
|
"replacer/pkg-1.1.0.0"
|
||||||
|
]
|
||||||
|
|
||||||
|
--EXPECT-OPTIMIZED--
|
||||||
|
[
|
||||||
|
"root/no-update-1.0.0.0 (locked)",
|
||||||
|
"root/dep-1.2.0.0",
|
||||||
|
"replaced/pkg-1.0.0.0",
|
||||||
|
"replacer/pkg-1.1.0.0"
|
||||||
|
]
|
|
@ -137,10 +137,14 @@ class PoolBuilderTest extends TestCase
|
||||||
|
|
||||||
$result = $this->getPackageResultSet($pool, $packageIds);
|
$result = $this->getPackageResultSet($pool, $packageIds);
|
||||||
|
|
||||||
|
sort($expect);
|
||||||
|
sort($result);
|
||||||
$this->assertSame($expect, $result, 'Unoptimized pool does not match expected package set');
|
$this->assertSame($expect, $result, 'Unoptimized pool does not match expected package set');
|
||||||
|
|
||||||
$optimizer = new PoolOptimizer(new DefaultPolicy());
|
$optimizer = new PoolOptimizer(new DefaultPolicy());
|
||||||
$result = $this->getPackageResultSet($optimizer->optimize($request, $pool), $packageIds);
|
$result = $this->getPackageResultSet($optimizer->optimize($request, $pool), $packageIds);
|
||||||
|
sort($expectOptimized);
|
||||||
|
sort($result);
|
||||||
$this->assertSame($expectOptimized, $result, 'Optimized pool does not match expected package set');
|
$this->assertSame($expectOptimized, $result, 'Optimized pool does not match expected package set');
|
||||||
|
|
||||||
chdir($oldCwd);
|
chdir($oldCwd);
|
||||||
|
|
Loading…
Reference in New Issue