From 89d4df990aaa345d9ca5f0c717d0a0969a38902c Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Mon, 22 Oct 2012 17:56:30 +0200 Subject: [PATCH] Use JsonFile to decode cached entries --- .../Repository/ComposerRepository.php | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/Composer/Repository/ComposerRepository.php b/src/Composer/Repository/ComposerRepository.php index ece870133..64a16a867 100644 --- a/src/Composer/Repository/ComposerRepository.php +++ b/src/Composer/Repository/ComposerRepository.php @@ -430,16 +430,18 @@ class ComposerRepository extends ArrayRepository implements NotifiableRepository break; } catch (\Exception $e) { - if ($contents = $this->cache->read($cacheKey)) { - if (!$this->degradedMode) { - $this->io->write(''.$e->getMessage().''); - $this->io->write(''.$this->url.' could not be fully loaded, package information was loaded from the local cache and may be out of date'); - } - $this->degradedMode = true; - $data = json_decode($contents, true); + if (!$retries) { + if ($contents = $this->cache->read($cacheKey)) { + if (!$this->degradedMode) { + $this->io->write(''.$e->getMessage().''); + $this->io->write(''.$this->url.' could not be fully loaded, package information was loaded from the local cache and may be out of date'); + } + $this->degradedMode = true; + $data = JsonFile::parseJson($contents, $this->cache->getRoot().$cacheKey); + + break; + } - break; - } elseif (!$retries) { throw $e; }