Browse Source

Use JsonFile to decode cached entries

Jordi Boggiano 12 years ago
parent
commit
89d4df990a
1 changed files with 10 additions and 8 deletions
  1. 10 8
      src/Composer/Repository/ComposerRepository.php

+ 10 - 8
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('<warning>'.$e->getMessage().'</warning>');
-                        $this->io->write('<warning>'.$this->url.' could not be fully loaded, package information was loaded from the local cache and may be out of date</warning>');
+                if (!$retries) {
+                    if ($contents = $this->cache->read($cacheKey)) {
+                        if (!$this->degradedMode) {
+                            $this->io->write('<warning>'.$e->getMessage().'</warning>');
+                            $this->io->write('<warning>'.$this->url.' could not be fully loaded, package information was loaded from the local cache and may be out of date</warning>');
+                        }
+                        $this->degradedMode = true;
+                        $data = JsonFile::parseJson($contents, $this->cache->getRoot().$cacheKey);
+
+                        break;
                     }
-                    $this->degradedMode = true;
-                    $data = json_decode($contents, true);
 
-                    break;
-                } elseif (!$retries) {
                     throw $e;
                 }