mirror of
https://github.com/composer/composer
synced 2025-05-11 09:32:55 +00:00
Fix ComposerRepository handling of offline state to allow resolution as long as everything is present in the cache, fixes #10116
This commit is contained in:
parent
edccad4e05
commit
a7963b7fed
2 changed files with 23 additions and 1 deletions
|
@ -1178,6 +1178,14 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
|
|||
throw $e;
|
||||
}
|
||||
|
||||
// try to detect offline state (if dns resolution fails it is pretty likely to keep failing) and avoid retrying in that case
|
||||
if ($e instanceof TransportException && $e->getStatusCode() === null) {
|
||||
$responseInfo = $e->getResponseInfo();
|
||||
if (isset($responseInfo['namelookup_time']) && $responseInfo['namelookup_time'] == 0) {
|
||||
$retries = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if ($retries) {
|
||||
usleep(100000);
|
||||
continue;
|
||||
|
@ -1349,7 +1357,7 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
|
|||
return $data;
|
||||
};
|
||||
|
||||
$reject = function ($e) use (&$retries, $httpDownloader, $filename, $options, &$reject, $accept, $io, $url, &$degradedMode, $repo) {
|
||||
$reject = function ($e) use (&$retries, $httpDownloader, $filename, $options, &$reject, $accept, $io, $url, &$degradedMode, $repo, $lastModifiedTime) {
|
||||
if ($e instanceof TransportException && $e->getStatusCode() === 404) {
|
||||
$repo->packagesNotFoundCache[$filename] = true;
|
||||
|
||||
|
@ -1361,6 +1369,14 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
|
|||
$retries = 0;
|
||||
}
|
||||
|
||||
// try to detect offline state (if dns resolution fails it is pretty likely to keep failing) and avoid retrying in that case
|
||||
if ($e instanceof TransportException && $e->getStatusCode() === null) {
|
||||
$responseInfo = $e->getResponseInfo();
|
||||
if (isset($responseInfo['namelookup_time']) && $responseInfo['namelookup_time'] == 0) {
|
||||
$retries = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (--$retries > 0) {
|
||||
usleep(100000);
|
||||
|
||||
|
@ -1372,6 +1388,11 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
|
|||
}
|
||||
$degradedMode = true;
|
||||
|
||||
// if the file is in the cache, we fake a 304 Not Modified to allow the process to continue
|
||||
if ($lastModifiedTime) {
|
||||
return $accept(new Response(array('url' => $url), 304, array(), ''));
|
||||
}
|
||||
|
||||
// special error code returned when network is being artificially disabled
|
||||
if ($e instanceof TransportException && $e->getStatusCode() === 499) {
|
||||
return $accept(new Response(array('url' => $url), 404, array(), ''));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue