From 191196de481e8fb652824b84fa504238dfabacb3 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Sat, 24 Oct 2020 10:58:23 +0200 Subject: [PATCH] Detect broken packagist.org mirrors and fix them on the fly, refs #9297 --- src/Composer/Repository/ComposerRepository.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Composer/Repository/ComposerRepository.php b/src/Composer/Repository/ComposerRepository.php index d64d3e6e6..8cd58602a 100644 --- a/src/Composer/Repository/ComposerRepository.php +++ b/src/Composer/Repository/ComposerRepository.php @@ -866,6 +866,12 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito $this->hasPartialPackages = !empty($data['packages']) && is_array($data['packages']); } + // Horrible hack to workaround https://github.com/composer/composer/issues/9297 and bad mirrors, should be disabled if possible once they fix things + if (!empty($data['metadata-url']) && !empty($data['list']) && $data['metadata-url'] === '/p/%package%.json' && $data['list'] === 'https://packagist.org/packages/list.json') { + file_put_contents('php://stderr', 'Composer 2 repository support for '.$this->url.' has been disabled due to what seems like a misconfiguration. If this is a packagist.org mirror we recommend removing it as Composer 2 handles network operations much faster and should work fine without.'.PHP_EOL); + unset($data['metadata-url']); + } + // metadata-url indicates V2 repo protocol so it takes over from all the V1 types // V2 only has lazyProviders and possibly partial packages, but no ability to process anything else, // V2 also supports async loading