1
0
Fork 0

Always assume the cache file is fresh when loading a package again which was already loaded, even if it lacks a last-modified header.

pull/9177/head
Jordi Boggiano 2020-09-07 17:00:02 +02:00 committed by GitHub
parent 9516d0dc98
commit cb3c71a18a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 7 deletions

View File

@ -568,17 +568,16 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
} elseif ($useLastModifiedCheck) { } elseif ($useLastModifiedCheck) {
if ($contents = $this->cache->read($cacheKey)) { if ($contents = $this->cache->read($cacheKey)) {
$contents = json_decode($contents, true); $contents = json_decode($contents, true);
if (isset($contents['last-modified'])) { // we already loaded some packages from this file, so assume it is fresh and avoid fetching it again
if (isset($alreadyLoaded[$name])) { if (isset($alreadyLoaded[$name])) {
$packages = $contents; $packages = $contents;
} else { } elseif (isset($contents['last-modified'])) {
$response = $this->fetchFileIfLastModified($url, $cacheKey, $contents['last-modified']); $response = $this->fetchFileIfLastModified($url, $cacheKey, $contents['last-modified']);
$packages = true === $response ? $contents : $response; $packages = true === $response ? $contents : $response;
} }
} }
} }
} }
}
if (!$packages) { if (!$packages) {
try { try {