From 281d8930ff1c15bd2a5b0dccea3ac8e87f6bd533 Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Thu, 12 Mar 2020 12:19:46 +0100 Subject: [PATCH] For dev extraction skip pool building, we already have a working package set Also reduce getProviders back to just providers, and add some todos --- src/Composer/DependencyResolver/Problem.php | 2 +- src/Composer/Installer.php | 2 +- src/Composer/Repository/ComposerRepository.php | 2 ++ src/Composer/Repository/RepositorySet.php | 18 +++++++++++++----- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/Composer/DependencyResolver/Problem.php b/src/Composer/DependencyResolver/Problem.php index 5f22914cc..ad9989d19 100644 --- a/src/Composer/DependencyResolver/Problem.php +++ b/src/Composer/DependencyResolver/Problem.php @@ -248,7 +248,7 @@ class Problem return array("- Root composer.json requires $packageName, it ", 'could not be found, it looks like its name is invalid, "'.$illegalChars.'" is not allowed in package names.'); } - if ($providers = $repositorySet->getProvidersAndReplacers($packageName)) { + if ($providers = $repositorySet->getProviders($packageName)) { $maxProviders = 20; $providersStr = implode(array_map(function ($p) { $description = $p['description'] ? ' '.substr($p['description'], 0, 100) : ''; diff --git a/src/Composer/Installer.php b/src/Composer/Installer.php index 7ed0ccda6..2bb38f885 100644 --- a/src/Composer/Installer.php +++ b/src/Composer/Installer.php @@ -565,7 +565,7 @@ class Installer $request->requireName($link->getTarget(), $link->getConstraint()); } - $pool = $repositorySet->createPool($request, $this->eventDispatcher); + $pool = $repositorySet->createPool($request, $this->eventDispatcher, true); $solver = new Solver($policy, $pool, $this->io, $repositorySet); try { diff --git a/src/Composer/Repository/ComposerRepository.php b/src/Composer/Repository/ComposerRepository.php index 2c153528a..e982de5b2 100644 --- a/src/Composer/Repository/ComposerRepository.php +++ b/src/Composer/Repository/ComposerRepository.php @@ -422,11 +422,13 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito public function getProviders($packageName) { if (!$this->providersApiUrl) { + // TODO should this return the info based on getPackages in other cases? return array(); } $result = $this->httpDownloader->get(str_replace('%package%', $packageName, $this->providersApiUrl), $this->options)->decodeJson(); + // TODO filter packageName out here? return $result['providers']; } diff --git a/src/Composer/Repository/RepositorySet.php b/src/Composer/Repository/RepositorySet.php index 506596a1b..b0d4153cd 100644 --- a/src/Composer/Repository/RepositorySet.php +++ b/src/Composer/Repository/RepositorySet.php @@ -163,7 +163,7 @@ class RepositorySet return $candidates; } - public function getProvidersAndReplacers($packageName) + public function getProviders($packageName) { $providers = array(); foreach ($this->repositories as $repository) { @@ -173,7 +173,7 @@ class RepositorySet } } else { foreach ($repository->getPackages() as $candidate) { - foreach (array_merge($candidate->getProvides(), $candidate->getReplaces()) as $link) { + foreach ($candidate->getProvides() as $link) { if ($packageName === $link->getTarget()) { $providers[] = array( 'name' => $candidate->getName(), @@ -200,10 +200,8 @@ class RepositorySet * * @return Pool */ - public function createPool(Request $request, EventDispatcher $eventDispatcher = null) + public function createPool(Request $request, EventDispatcher $eventDispatcher = null, $allPackages = false) { - $poolBuilder = new PoolBuilder($this->acceptableStabilities, $this->stabilityFlags, $this->rootAliases, $this->rootReferences, $eventDispatcher); - foreach ($this->repositories as $repo) { if (($repo instanceof InstalledRepositoryInterface || $repo instanceof InstalledRepository) && !$this->allowInstalledRepositories) { throw new \LogicException('The pool can not accept packages from an installed repository'); @@ -212,6 +210,16 @@ class RepositorySet $this->locked = true; + if ($allPackages) { + $packages = array(); + foreach ($this->repositories as $repository) { + $packages = array_merge($packages, $repository->getPackages()); + } + return new Pool($packages); + } + + $poolBuilder = new PoolBuilder($this->acceptableStabilities, $this->stabilityFlags, $this->rootAliases, $this->rootReferences, $eventDispatcher); + return $poolBuilder->buildPool($this->repositories, $request); }