diff --git a/src/Composer/Repository/Vcs/SvnDriver.php b/src/Composer/Repository/Vcs/SvnDriver.php index d6c7274fd..af29720a2 100644 --- a/src/Composer/Repository/Vcs/SvnDriver.php +++ b/src/Composer/Repository/Vcs/SvnDriver.php @@ -148,7 +148,7 @@ class SvnDriver extends VcsDriver throw $e; } // remember a not-existent composer.json - $composer = []; + $composer = null; } if ($this->shouldCache($identifier)) { @@ -158,6 +158,11 @@ class SvnDriver extends VcsDriver $this->infoCache[$identifier] = $composer; } + // old cache files had '' stored instead of null due to af3783b5f40bae32a23e353eaf0a00c9b8ce82e2, so we make sure here that we always return null or array + if (!is_array($this->infoCache[$identifier])) { + return null; + } + return $this->infoCache[$identifier]; } diff --git a/src/Composer/Repository/Vcs/VcsDriver.php b/src/Composer/Repository/Vcs/VcsDriver.php index 484082de0..e53b9bd23 100644 --- a/src/Composer/Repository/Vcs/VcsDriver.php +++ b/src/Composer/Repository/Vcs/VcsDriver.php @@ -109,7 +109,7 @@ abstract class VcsDriver implements VcsDriverInterface /** * @param string $identifier * - * @return array|null + * @return array|null */ protected function getBaseComposerInformation(string $identifier): ?array { @@ -121,6 +121,10 @@ abstract class VcsDriver implements VcsDriverInterface $composer = JsonFile::parseJson($composerFileContent, $identifier . ':composer.json'); + if ([] === $composer || !is_array($composer)) { + return null; + } + if (empty($composer['time']) && null !== ($changeDate = $this->getChangeDate($identifier))) { $composer['time'] = $changeDate->format(DATE_RFC3339); } @@ -134,7 +138,7 @@ abstract class VcsDriver implements VcsDriverInterface public function hasComposerFile(string $identifier): bool { try { - return (bool) $this->getComposerInformation($identifier); + return null !== $this->getComposerInformation($identifier); } catch (TransportException $e) { } diff --git a/src/Composer/Repository/Vcs/VcsDriverInterface.php b/src/Composer/Repository/Vcs/VcsDriverInterface.php index 4a05e8d4b..fd5684851 100644 --- a/src/Composer/Repository/Vcs/VcsDriverInterface.php +++ b/src/Composer/Repository/Vcs/VcsDriverInterface.php @@ -32,7 +32,7 @@ interface VcsDriverInterface * Return the composer.json file information * * @param string $identifier Any identifier to a specific branch/tag/commit - * @return mixed[]|null containing all infos from the composer.json file + * @return mixed[]|null Array containing all infos from the composer.json file, or null to denote that no file was present */ public function getComposerInformation(string $identifier): ?array;