From 0961e16795dffb5a1ed10eac209e28e44dfcdb2e Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Thu, 29 Nov 2018 19:31:41 +0100 Subject: [PATCH] Add support for new metadata-url repo attribute --- .../Repository/ComposerRepository.php | 27 ++++++++----------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/src/Composer/Repository/ComposerRepository.php b/src/Composer/Repository/ComposerRepository.php index 939fb84ba..101c23bcb 100644 --- a/src/Composer/Repository/ComposerRepository.php +++ b/src/Composer/Repository/ComposerRepository.php @@ -667,6 +667,17 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito $this->hasPartialPackages = !empty($data['packages']) && is_array($data['packages']); } + // metadata-url indiates V2 repo protocol so it takes over from all the V1 types + // V2 only has lazyProviders and no ability to process anything else, plus support for async loading + if (!empty($data['metadata-url'])) { + $this->lazyProvidersUrl = $this->canonicalizeUrl($data['metadata-url']); + $this->providersUrl = null; + $this->hasProviders = false; + $this->hasPartialPackages = false; + $this->allowSslDowngrade = false; + unset($data['providers-url'], $data['providers'], $data['providers-includes']); + } + if ($this->allowSslDowngrade) { $this->url = str_replace('https://', 'http://', $this->url); $this->baseUrl = str_replace('https://', 'http://', $this->baseUrl); @@ -681,22 +692,6 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito $this->hasProviders = true; } - // TODO this is for testing only, remove once packagist reports v2 protocol support - if (preg_match('{^https?://repo\.packagist\.org/?$}i', $this->url)) { - $this->repoConfig['force-lazy-providers'] = true; - } - - // force values for packagist - if (preg_match('{^https?://repo\.packagist\.org/?$}i', $this->url) && !empty($this->repoConfig['force-lazy-providers'])) { - $this->url = 'https://repo.packagist.org'; - $this->baseUrl = 'https://repo.packagist.org'; - $this->lazyProvidersUrl = $this->canonicalizeUrl('https://repo.packagist.org/p/%package%.json'); - $this->providersUrl = null; - } elseif (!empty($this->repoConfig['force-lazy-providers'])) { - $this->lazyProvidersUrl = $this->canonicalizeUrl('/p/%package%.json'); - $this->providersUrl = null; - } - return $this->rootData = $data; }