From 3b6d517ce0f44e6b6022029b45903ee3f0f9570b Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Thu, 14 Nov 2019 09:57:59 +0100 Subject: [PATCH] Return 404s in ComposerRepository when network is disabled instead of failing hard --- 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 a53b37c33..e4cfbba83 100644 --- a/src/Composer/Repository/ComposerRepository.php +++ b/src/Composer/Repository/ComposerRepository.php @@ -31,6 +31,7 @@ use Composer\Downloader\TransportException; use Composer\Semver\Constraint\ConstraintInterface; use Composer\Semver\Constraint\Constraint; use Composer\Semver\Constraint\EmptyConstraint; +use Composer\Util\Http\Response; /** * @author Jordi Boggiano @@ -1140,6 +1141,11 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito } $degradedMode = true; + // 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(), '')); + } + throw $e; };