Avoid storing duplicate packages when loading the same package twice
parent
67a88880ec
commit
f2befc46c9
|
@ -209,17 +209,6 @@ class PoolBuilder
|
||||||
$this->unacceptableFixedPackages = $prePoolCreateEvent->getUnacceptableFixedPackages();
|
$this->unacceptableFixedPackages = $prePoolCreateEvent->getUnacceptableFixedPackages();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Filter duplicate packages
|
|
||||||
// TODO: can we optimize this so that we don't even end up having dupes here?
|
|
||||||
$presentPackages = array();
|
|
||||||
foreach ($this->packages as $i => $package) {
|
|
||||||
if (isset($presentPackages[$package->getUniqueName()])) {
|
|
||||||
unset($this->packages[$i]);
|
|
||||||
} else {
|
|
||||||
$presentPackages[$package->getUniqueName()] = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$pool = new Pool($this->packages, $this->unacceptableFixedPackages);
|
$pool = new Pool($this->packages, $this->unacceptableFixedPackages);
|
||||||
|
|
||||||
$this->aliasMap = array();
|
$this->aliasMap = array();
|
||||||
|
@ -235,7 +224,7 @@ class PoolBuilder
|
||||||
{
|
{
|
||||||
// Maybe it was already marked before but not loaded yet. In that case
|
// Maybe it was already marked before but not loaded yet. In that case
|
||||||
// we have to extend the constraint (we don't check if they match because
|
// we have to extend the constraint (we don't check if they match because
|
||||||
// MultiConstraint::create() will optimize anyway
|
// MultiConstraint::create() will optimize anyway)
|
||||||
if (isset($this->packagesToLoad[$name]) && !Intervals::isSubsetOf($constraint, $this->packagesToLoad[$name])) {
|
if (isset($this->packagesToLoad[$name]) && !Intervals::isSubsetOf($constraint, $this->packagesToLoad[$name])) {
|
||||||
$constraint = MultiConstraint::create(array($this->packagesToLoad[$name], $constraint), false);
|
$constraint = MultiConstraint::create(array($this->packagesToLoad[$name], $constraint), false);
|
||||||
}
|
}
|
||||||
|
@ -256,6 +245,13 @@ class PoolBuilder
|
||||||
// yet so we get the required package versions
|
// yet so we get the required package versions
|
||||||
$this->packagesToLoad[$name] = MultiConstraint::create(array($this->loadedPackages[$name], $constraint), false);
|
$this->packagesToLoad[$name] = MultiConstraint::create(array($this->loadedPackages[$name], $constraint), false);
|
||||||
unset($this->loadedPackages[$name]);
|
unset($this->loadedPackages[$name]);
|
||||||
|
|
||||||
|
// remove all already-loaded packages matching those to be loaded to avoid duplicates
|
||||||
|
foreach ($this->packages as $index => $pkg) {
|
||||||
|
if ($pkg->getName() === $name) {
|
||||||
|
unset($this->packages[$index]);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function loadPackagesMarkedForLoading(Request $request, $repositories)
|
private function loadPackagesMarkedForLoading(Request $request, $repositories)
|
||||||
|
|
|
@ -23,7 +23,7 @@ Tests if version constraint is expanded. If not, dep/dep 3.0.0 would not be load
|
||||||
--EXPECT--
|
--EXPECT--
|
||||||
[
|
[
|
||||||
"root/req-1.0.0.0",
|
"root/req-1.0.0.0",
|
||||||
"dep/dep-2.3.4.0",
|
|
||||||
"dep/dep2-2.3.4.0",
|
"dep/dep2-2.3.4.0",
|
||||||
|
"dep/dep-2.3.4.0",
|
||||||
"dep/dep-2.3.5.0"
|
"dep/dep-2.3.5.0"
|
||||||
]
|
]
|
||||||
|
|
|
@ -25,8 +25,8 @@ Tests if version constraint is expanded. If not, dep/dep 3.0.0 would not be load
|
||||||
--EXPECT--
|
--EXPECT--
|
||||||
[
|
[
|
||||||
"root/req-1.0.0.0",
|
"root/req-1.0.0.0",
|
||||||
|
"dep/dep2-2.3.4.0",
|
||||||
"dep/dep-2.3.4.0",
|
"dep/dep-2.3.4.0",
|
||||||
"dep/dep-2.3.5.0",
|
"dep/dep-2.3.5.0",
|
||||||
"dep/dep2-2.3.4.0",
|
|
||||||
"dep/dep-3.0.0.0"
|
"dep/dep-3.0.0.0"
|
||||||
]
|
]
|
||||||
|
|
Loading…
Reference in New Issue