1
0
Fork 0

Fix findPackage(s) implementation

pull/7904/head
Jordi Boggiano 2018-11-12 17:44:18 +01:00
parent 346de47af2
commit 655a784fac
1 changed files with 13 additions and 4 deletions

View File

@ -127,15 +127,24 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
*/
public function findPackage($name, $constraint)
{
if (!$this->hasProviders()) {
return parent::findPackage($name, $constraint);
}
// this call initializes loadRootServerFile which is needed for the rest below to work
$hasProviders = $this->hasProviders();
$name = strtolower($name);
if (!$constraint instanceof ConstraintInterface) {
$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) {
if ($name === $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
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;
});
}