Fix findPackage(s) implementation

main
Jordi Boggiano 6 years ago
parent 346de47af2
commit 655a784fac

@ -127,15 +127,24 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
*/ */
public function findPackage($name, $constraint) public function findPackage($name, $constraint)
{ {
if (!$this->hasProviders()) { // this call initializes loadRootServerFile which is needed for the rest below to work
return parent::findPackage($name, $constraint); $hasProviders = $this->hasProviders();
}
$name = strtolower($name); $name = strtolower($name);
if (!$constraint instanceof ConstraintInterface) { if (!$constraint instanceof ConstraintInterface) {
$constraint = $this->versionParser->parseConstraints($constraint); $constraint = $this->versionParser->parseConstraints($constraint);
} }
// TODO we need a new way for the repo to report this v2 protocol somehow
if ($this->lazyProvidersUrl) {
return $this->loadAsyncPackages(array($name => $constraint), function ($name, $stability) {
return true;
});
}
if (!$hasProviders) {
return parent::findPackage($name, $constraint);
}
foreach ($this->getProviderNames() as $providerName) { foreach ($this->getProviderNames() as $providerName) {
if ($name === $providerName) { if ($name === $providerName) {
$packages = $this->whatProvides($providerName); $packages = $this->whatProvides($providerName);
@ -162,7 +171,7 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
// TODO we need a new way for the repo to report this v2 protocol somehow // TODO we need a new way for the repo to report this v2 protocol somehow
if ($this->lazyProvidersUrl) { if ($this->lazyProvidersUrl) {
return $this->loadAsyncPackages(array($name => new EmptyConstraint()), function ($name, $stability) { return $this->loadAsyncPackages(array($name => $constraint ?: new EmptyConstraint()), function ($name, $stability) {
return true; return true;
}); });
} }

Loading…
Cancel
Save