1
0
Fork 0

Cache root packages.json, refs #10326

pull/10331/head
Jordi Boggiano 2021-12-03 14:49:41 +01:00
parent 483eac1c2f
commit 7c8267f57c
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC
1 changed files with 11 additions and 1 deletions

View File

@ -931,7 +931,17 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
throw new \RuntimeException('You must enable the openssl extension in your php.ini to load information from '.$this->url);
}
$data = $this->fetchFile($this->getPackagesJsonUrl(), 'packages.json');
if ($cachedData = $this->cache->read('packages.json')) {
$cachedData = json_decode($cachedData, true);
if (isset($cachedData['last-modified'])) {
$response = $this->fetchFileIfLastModified($this->getPackagesJsonUrl(), 'packages.json', $cachedData['last-modified']);
$data = true === $response ? $cachedData : $response;
}
}
if (!isset($data)) {
$data = $this->fetchFile($this->getPackagesJsonUrl(), 'packages.json', null, true);
}
if (!empty($data['notify-batch'])) {
$this->notifyUrl = $this->canonicalizeUrl($data['notify-batch']);