1
0
Fork 0

Simplify package loading

pull/8850/head
Yanick Witschi 2020-05-06 17:14:40 +02:00 committed by Jordi Boggiano
parent 779b56ab2b
commit 0955d38374
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC
1 changed files with 5 additions and 11 deletions

View File

@ -255,10 +255,11 @@ class PoolBuilder
$this->loadedNames[$name] = $constraint; $this->loadedNames[$name] = $constraint;
} }
$preLoad = $this->packagesToLoad; $packageBatch = $this->packagesToLoad;
$this->packagesToLoad = array();
foreach ($repositories as $repository) { foreach ($repositories as $repository) {
if (empty($this->packagesToLoad)) { if (empty($packageBatch)) {
break; break;
} }
@ -267,23 +268,16 @@ class PoolBuilder
if ($repository instanceof PlatformRepository || $repository === $request->getLockedRepository()) { if ($repository instanceof PlatformRepository || $repository === $request->getLockedRepository()) {
continue; continue;
} }
$result = $repository->loadPackages($this->packagesToLoad, $this->acceptableStabilities, $this->stabilityFlags); $result = $repository->loadPackages($packageBatch, $this->acceptableStabilities, $this->stabilityFlags);
foreach ($result['namesFound'] as $name) { foreach ($result['namesFound'] as $name) {
// avoid loading the same package again from other repositories once it has been found // avoid loading the same package again from other repositories once it has been found
unset($this->packagesToLoad[$name]); unset($packageBatch[$name]);
} }
foreach ($result['packages'] as $package) { foreach ($result['packages'] as $package) {
$this->loadPackage($request, $package); $this->loadPackage($request, $package);
} }
} }
// Make sure we empty the packagesToLoad here as it would result
// in an endless loop if the array remains unchanged.
// This could happen with non-existent packages for example.
if ($preLoad == $this->packagesToLoad) {
$this->packagesToLoad = array();
}
} }
private function loadPackage(Request $request, PackageInterface $package, $propagateUpdate = true) private function loadPackage(Request $request, PackageInterface $package, $propagateUpdate = true)