From 46e35bc8d7027c7355d0950899a8b27f60e53a21 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Thu, 30 Jan 2020 14:17:49 +0100 Subject: [PATCH] Fix 5.3/undef var issues --- src/Composer/Repository/ComposerRepository.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/Composer/Repository/ComposerRepository.php b/src/Composer/Repository/ComposerRepository.php index 626bf119f..3919d2a6b 100644 --- a/src/Composer/Repository/ComposerRepository.php +++ b/src/Composer/Repository/ComposerRepository.php @@ -34,6 +34,7 @@ use Composer\Semver\Constraint\Constraint; use Composer\Semver\Constraint\EmptyConstraint; use Composer\Util\Http\Response; use Composer\Util\MetadataMinifier; +use React\Promise\Util as PromiseUtil; /** * @author Jordi Boggiano @@ -67,10 +68,12 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito private $partialPackagesByName; /** + * TODO v3 should make this private once we can drop PHP 5.3 support + * @private * @var array list of package names which returned a 404 and should not be re-fetched in case loadPackage is called several times * useful for v2 metadata repositories with lazy providers */ - private $packagesNotFoundCache = array(); + public $packagesNotFoundCache = array(); /** * TODO v3 should make this private once we can drop PHP 5.3 support * @private @@ -1086,7 +1089,7 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito $retries = 3; if (isset($this->packagesNotFoundCache[$filename])) { - return \React\Promise\Util::promiseFor(array('packages' => array())); + return PromiseUtil::promiseFor(array('packages' => array())); } $httpDownloader = $this->httpDownloader; @@ -1101,11 +1104,12 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito $url = $this->url; $cache = $this->cache; $degradedMode =& $this->degradedMode; + $repo = $this; - $accept = function ($response) use ($io, $url, $cache, $cacheKey) { + $accept = function ($response) use ($io, $url, $filename, $cache, $cacheKey, $repo) { // package not found is acceptable for a v2 protocol repository if ($response->getStatusCode() === 404) { - $this->packagesNotFoundCache[$filename] = true; + $repo->packagesNotFoundCache[$filename] = true; return array('packages' => array()); } @@ -1128,9 +1132,9 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito return $data; }; - $reject = function ($e) use (&$retries, $httpDownloader, $filename, $options, &$reject, $accept, $io, $url, &$degradedMode) { + $reject = function ($e) use (&$retries, $httpDownloader, $filename, $options, &$reject, $accept, $io, $url, &$degradedMode, $repo) { if ($e instanceof TransportException && $e->getStatusCode() === 404) { - $this->packagesNotFoundCache[$filename] = true; + $repo->packagesNotFoundCache[$filename] = true; return false; }