1
0
Fork 0

Small fixes

pull/7904/head
Jordi Boggiano 2018-11-12 17:21:23 +01:00
parent 09fd239f24
commit 346de47af2
3 changed files with 30 additions and 8 deletions

View File

@ -374,7 +374,7 @@ EOT
{
$factory = new Factory();
return $factory->createDownloadManager($io, $config);
return $factory->createDownloadManager($io, $config, $factory->createHttpDownloader($io, $config));
}
protected function createInstallationManager()

View File

@ -28,6 +28,7 @@ use Composer\EventDispatcher\EventDispatcher;
use Composer\Downloader\TransportException;
use Composer\Semver\Constraint\ConstraintInterface;
use Composer\Semver\Constraint\Constraint;
use Composer\Semver\Constraint\EmptyConstraint;
/**
* @author Jordi Boggiano <j.boggiano@seld.be>
@ -156,9 +157,19 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
*/
public function findPackages($name, $constraint = null)
{
if (!$this->hasProviders()) {
// this call initializes loadRootServerFile which is needed for the rest below to work
$hasProviders = $this->hasProviders();
// 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 true;
});
}
if (!$hasProviders) {
return parent::findPackages($name, $constraint);
}
// normalize name
$name = strtolower($name);
@ -197,10 +208,14 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
public function loadPackages(array $packageNameMap, $isPackageAcceptableCallable)
{
// this call initializes loadRootServerFile which is needed for the rest below to work
$hasProviders = $this->hasProviders();
// TODO we need a new way for the repo to report this v2 protocol somehow
if ($this->lazyProvidersUrl) {
return $this->loadAsyncPackages($packageNameMap, $isPackageAcceptableCallable);
}
if (!$this->hasProviders()) {
if (!$hasProviders) {
return parent::loadPackages($packageNameMap, $isPackageAcceptableCallable);
}
@ -225,6 +240,7 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
}
$packages = array_merge($packages, $matches);
}
return $packages;
}
@ -528,6 +544,11 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
if ($this->lazyProvidersUrl) {
foreach ($packageNames as $name => $constraint) {
// skip platform packages, root package and composer-plugin-api
if (preg_match(PlatformRepository::PLATFORM_PACKAGE_REGEX, $name) || '__root__' === $name || 'composer-plugin-api' === $name) {
continue;
}
$url = str_replace('%package%', $name, $this->lazyProvidersUrl);
$cacheKey = 'provider-'.strtr($name, '/', '$').'.json';

View File

@ -13,6 +13,7 @@
namespace Composer\Repository;
use Composer\Package\PackageInterface;
use Composer\Semver\Constraint\ConstraintInterface;
/**
* Repository interface.
@ -38,8 +39,8 @@ interface RepositoryInterface extends \Countable
/**
* Searches for the first match of a package by name and version.
*
* @param string $name package name
* @param string|\Composer\Semver\Constraint\ConstraintInterface $constraint package version or version constraint to match against
* @param string $name package name
* @param string|ConstraintInterface $constraint package version or version constraint to match against
*
* @return PackageInterface|null
*/
@ -48,8 +49,8 @@ interface RepositoryInterface extends \Countable
/**
* Searches for all packages matching a name and optionally a version.
*
* @param string $name package name
* @param string|\Composer\Semver\Constraint\ConstraintInterface $constraint package version or version constraint to match against
* @param string $name package name
* @param string|ConstraintInterface $constraint package version or version constraint to match against
*
* @return PackageInterface[]
*/
@ -66,7 +67,7 @@ interface RepositoryInterface extends \Countable
/**
* Returns list of registered packages with the supplied name
*
* @param bool[] $packageNameMap
* @param ConstraintInterface[] $packageNameMap package names pointing to constraints
* @param $isPackageAcceptableCallable
* @return PackageInterface[]
*/