diff options
author | Ferdinand Thiessen <opensource@fthiessen.de> | 2024-06-27 15:14:26 +0200 |
---|---|---|
committer | Ferdinand Thiessen <opensource@fthiessen.de> | 2024-07-03 11:37:49 +0200 |
commit | 8fc498fb820ed1459475eec98cfedb23161dd643 (patch) | |
tree | 600fec2bac33ad66d1b06eedfd8cca734ab9e070 /lib | |
parent | acb95d5c0f5d0f3d5ea4a88b4adf1be62f52c29a (diff) | |
download | nextcloud-server-8fc498fb820ed1459475eec98cfedb23161dd643.tar.gz nextcloud-server-8fc498fb820ed1459475eec98cfedb23161dd643.zip |
fix(IntegrityCheck): Ensure the check is run if no results are available
If there are no cached results the current implementation was also returning an empty array,
but this was the same as when there was a successful run.
So to distinguish this we return `null` if there are *no* results.
In this case we need to rerun the integrity checker.
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/IntegrityCheck/Checker.php | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/lib/private/IntegrityCheck/Checker.php b/lib/private/IntegrityCheck/Checker.php index a6de3cf6030..d38ccf497f4 100644 --- a/lib/private/IntegrityCheck/Checker.php +++ b/lib/private/IntegrityCheck/Checker.php @@ -373,7 +373,7 @@ class Checker { */ public function hasPassedCheck(): bool { $results = $this->getResults(); - if (empty($results)) { + if ($results !== null && empty($results)) { return true; } @@ -381,15 +381,20 @@ class Checker { } /** - * @return array + * @return array|null Either the results or null if no results available */ - public function getResults(): array { + public function getResults(): array|null { $cachedResults = $this->cache->get(self::CACHE_KEY); if (!\is_null($cachedResults) and $cachedResults !== false) { return json_decode($cachedResults, true); } - return $this->appConfig?->getValueArray('core', self::CACHE_KEY, lazy: true) ?? []; + if ($this->appConfig?->hasKey('core', self::CACHE_KEY, lazy: true)) { + return $this->appConfig->getValueArray('core', self::CACHE_KEY, lazy: true); + } + + // No results available + return null; } /** @@ -399,7 +404,7 @@ class Checker { * @param array $result */ private function storeResults(string $scope, array $result) { - $resultArray = $this->getResults(); + $resultArray = $this->getResults() ?? []; unset($resultArray[$scope]); if (!empty($result)) { $resultArray[$scope] = $result; |