diff --git a/src/Composer/Repository/Vcs/BitbucketDriver.php b/src/Composer/Repository/Vcs/BitbucketDriver.php index c360bad10..08f119527 100644 --- a/src/Composer/Repository/Vcs/BitbucketDriver.php +++ b/src/Composer/Repository/Vcs/BitbucketDriver.php @@ -119,10 +119,14 @@ abstract class BitbucketDriver extends VcsDriver if (!isset($this->infoCache[$identifier])) { if ($this->shouldCache($identifier) && $res = $this->cache->read($identifier)) { - return $this->infoCache[$identifier] = JsonFile::parseJson($res); - } + $composer = JsonFile::parseJson($res); + } else { + $composer = $this->getBaseComposerInformation($identifier); - $composer = $this->getBaseComposerInformation($identifier); + if ($this->shouldCache($identifier)) { + $this->cache->write($identifier, json_encode($composer)); + } + } if ($composer) { // specials for bitbucket @@ -173,10 +177,6 @@ abstract class BitbucketDriver extends VcsDriver } $this->infoCache[$identifier] = $composer; - - if ($this->shouldCache($identifier)) { - $this->cache->write($identifier, json_encode($composer)); - } } return $this->infoCache[$identifier]; diff --git a/src/Composer/Repository/Vcs/GitHubDriver.php b/src/Composer/Repository/Vcs/GitHubDriver.php index 7abda8164..26904b12f 100644 --- a/src/Composer/Repository/Vcs/GitHubDriver.php +++ b/src/Composer/Repository/Vcs/GitHubDriver.php @@ -150,10 +150,14 @@ class GitHubDriver extends VcsDriver if (!isset($this->infoCache[$identifier])) { if ($this->shouldCache($identifier) && $res = $this->cache->read($identifier)) { - return $this->infoCache[$identifier] = JsonFile::parseJson($res); - } + $composer = JsonFile::parseJson($res); + } else { + $composer = $this->getBaseComposerInformation($identifier); - $composer = $this->getBaseComposerInformation($identifier); + if ($this->shouldCache($identifier)) { + $this->cache->write($identifier, json_encode($composer)); + } + } if ($composer) { // specials for github @@ -172,10 +176,6 @@ class GitHubDriver extends VcsDriver } } - if ($this->shouldCache($identifier)) { - $this->cache->write($identifier, json_encode($composer)); - } - $this->infoCache[$identifier] = $composer; } diff --git a/src/Composer/Repository/Vcs/GitLabDriver.php b/src/Composer/Repository/Vcs/GitLabDriver.php index 2878f3f74..bb5c2121e 100644 --- a/src/Composer/Repository/Vcs/GitLabDriver.php +++ b/src/Composer/Repository/Vcs/GitLabDriver.php @@ -130,10 +130,14 @@ class GitLabDriver extends VcsDriver if (!isset($this->infoCache[$identifier])) { if ($this->shouldCache($identifier) && $res = $this->cache->read($identifier)) { - return $this->infoCache[$identifier] = JsonFile::parseJson($res); - } + $composer = JsonFile::parseJson($res); + } else { + $composer = $this->getBaseComposerInformation($identifier); - $composer = $this->getBaseComposerInformation($identifier); + if ($this->shouldCache($identifier)) { + $this->cache->write($identifier, json_encode($composer)); + } + } if ($composer) { // specials for gitlab (this data is only available if authentication is provided) @@ -145,10 +149,6 @@ class GitLabDriver extends VcsDriver } } - if ($this->shouldCache($identifier)) { - $this->cache->write($identifier, json_encode($composer)); - } - $this->infoCache[$identifier] = $composer; } @@ -446,7 +446,7 @@ class GitLabDriver extends VcsDriver if (!$moreThanGuestAccess) { $this->io->writeError('GitLab token with Guest only access detected'); - return $this->attemptCloneFallback(); + return $this->attemptCloneFallback(); } }