From 0955d38374f5cdca41f398b73d55c9198cc18d07 Mon Sep 17 00:00:00 2001 From: Yanick Witschi Date: Wed, 6 May 2020 17:14:40 +0200 Subject: [PATCH] Simplify package loading --- src/Composer/DependencyResolver/PoolBuilder.php | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/Composer/DependencyResolver/PoolBuilder.php b/src/Composer/DependencyResolver/PoolBuilder.php index 965f5e8ff..97c177208 100644 --- a/src/Composer/DependencyResolver/PoolBuilder.php +++ b/src/Composer/DependencyResolver/PoolBuilder.php @@ -255,10 +255,11 @@ class PoolBuilder $this->loadedNames[$name] = $constraint; } - $preLoad = $this->packagesToLoad; + $packageBatch = $this->packagesToLoad; + $this->packagesToLoad = array(); foreach ($repositories as $repository) { - if (empty($this->packagesToLoad)) { + if (empty($packageBatch)) { break; } @@ -267,23 +268,16 @@ class PoolBuilder if ($repository instanceof PlatformRepository || $repository === $request->getLockedRepository()) { continue; } - $result = $repository->loadPackages($this->packagesToLoad, $this->acceptableStabilities, $this->stabilityFlags); + $result = $repository->loadPackages($packageBatch, $this->acceptableStabilities, $this->stabilityFlags); foreach ($result['namesFound'] as $name) { // 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) { $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)