Skip to content

Commit 78c9f7b

Browse files
committed
Fix reading series from cache if fetching fails
`Fetcher::getByUri()` returns a string (and since it is a public method we don't want to change that for now), but we check for `false`; so we change that. We also use `file_exists()` instead of `Cache::isFileCached()` because the method is actually called `Cache::fileIsCached()` but appears to be broken due to applying `::getCacheablePath()` again. Furthermore the other methods of `Cache` also use `file_exists()` directly. Since `Cache::fileIsCached()` is public, we do not remove the otherwise unused method yet.
1 parent 8a4ca65 commit 78c9f7b

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

lib/php/libsdk/SDK/Cache.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public function getCachedContent(string $path, bool $relative = false) : ?string
7979
{/*{{{*/
8080
$p = $this->getCacheablePath($path, $relative);
8181

82-
if ($this->isFileCached($p)) {
82+
if (file_exists($p)) {
8383
return file_get_contents($p);
8484
}
8585

lib/php/libsdk/SDK/Config.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ public static function getKnownBranches() : array
146146
$fetcher = new Fetcher(self::$depsHost, self::$depsPort, self::$depsUriScheme);
147147

148148
$tmp = $fetcher->getByUri(self::$depsBaseUri . "/series/");
149-
if (false !== $tmp) {
149+
if ("" !== $tmp) {
150150
$data = array();
151151
if (preg_match_all(",packages-(.+)-(v[cs]\d+)-(x86|x64|arm64)-(stable|staging)\.txt,Us", $tmp, $m, PREG_SET_ORDER)) {
152152
foreach ($m as $b) {

0 commit comments

Comments
 (0)