Fix support for partial provider repos
parent
98a599d6c3
commit
7259630cbe
|
@ -59,6 +59,8 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
|
|||
protected $distMirrors;
|
||||
private $degradedMode = false;
|
||||
private $rootData;
|
||||
private $hasPartialPackages;
|
||||
private $partialPackagesByName;
|
||||
|
||||
public function __construct(array $repoConfig, IOInterface $io, Config $config, EventDispatcher $eventDispatcher = null, RemoteFilesystem $rfs = null)
|
||||
{
|
||||
|
@ -280,6 +282,11 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
|
|||
return $this->providers[$name];
|
||||
}
|
||||
|
||||
if ($this->hasPartialPackages && null === $this->partialPackagesByName) {
|
||||
$this->initializePartialPackages();
|
||||
}
|
||||
|
||||
if (!$this->hasPartialPackages || !isset($this->partialPackagesByName[$name])) {
|
||||
// skip platform packages, root package and composer-plugin-api
|
||||
if (preg_match(PlatformRepository::PLATFORM_PACKAGE_REGEX, $name) || '__root__' === $name || 'composer-plugin-api' === $name) {
|
||||
return array();
|
||||
|
@ -340,9 +347,19 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
|
|||
}
|
||||
}
|
||||
|
||||
$loadingPartialPackage = false;
|
||||
} else {
|
||||
$packages = array('packages' => array('versions' => $this->partialPackagesByName[$name]));
|
||||
$loadingPartialPackage = true;
|
||||
}
|
||||
|
||||
$this->providers[$name] = array();
|
||||
foreach ($packages['packages'] as $versions) {
|
||||
foreach ($versions as $version) {
|
||||
if (!$loadingPartialPackage && $this->hasPartialPackages && isset($this->partialPackagesByName[$version['name']])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// avoid loading the same objects twice
|
||||
if (isset($this->providersByUid[$version['uid']])) {
|
||||
// skip if already assigned
|
||||
|
@ -492,6 +509,8 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
|
|||
if (!empty($data['providers-lazy-url'])) {
|
||||
$this->lazyProvidersUrl = $this->canonicalizeUrl($data['providers-lazy-url']);
|
||||
$this->hasProviders = true;
|
||||
|
||||
$this->hasPartialPackages = !empty($data['packages']) && is_array($data['packages']);
|
||||
}
|
||||
|
||||
if ($this->allowSslDowngrade) {
|
||||
|
@ -754,4 +773,22 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This initializes the packages key of a partial packages.json that contain some packages inlined + a providers-lazy-url
|
||||
*
|
||||
* This should only be called once
|
||||
*/
|
||||
private function initializePartialPackages()
|
||||
{
|
||||
$rootData = $this->loadRootServerFile();
|
||||
|
||||
$this->partialPackagesByName = array();
|
||||
foreach ($rootData['packages'] as $package => $versions) {
|
||||
$this->partialPackagesByName[strtolower($package)] = $versions;
|
||||
}
|
||||
|
||||
// wipe rootData as it is fully consumed at this point and this saves some memory
|
||||
$this->rootData = true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue