aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorprovokateurin <kate@provokateurin.de>2024-11-15 14:25:51 +0100
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>2024-11-25 11:43:37 +0000
commit8d97e759b135e4fc375809c53608eca3338345c6 (patch)
tree0a615980f4ecc95f19b24641bed1af8ec15227ad
parent4260dd1517a2f8fe38b0bb0beb51be28f808eb04 (diff)
downloadnextcloud-server-8d97e759b135e4fc375809c53608eca3338345c6.tar.gz
nextcloud-server-8d97e759b135e4fc375809c53608eca3338345c6.zip
fix(OCMDiscoveryService): Also cache error results during discoverybackport/49311/stable28
Signed-off-by: provokateurin <kate@provokateurin.de>
-rw-r--r--lib/private/OCM/OCMDiscoveryService.php10
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/private/OCM/OCMDiscoveryService.php b/lib/private/OCM/OCMDiscoveryService.php
index ac9bf2a3965..dd2f3d4e058 100644
--- a/lib/private/OCM/OCMDiscoveryService.php
+++ b/lib/private/OCM/OCMDiscoveryService.php
@@ -72,7 +72,12 @@ class OCMDiscoveryService implements IOCMDiscoveryService {
if (!$skipCache) {
try {
- $this->provider->import(json_decode($this->cache->get($remote) ?? '', true, 8, JSON_THROW_ON_ERROR) ?? []);
+ $cached = $this->cache->get($remote);
+ if ($cached === false) {
+ throw new OCMProviderException('Previous discovery failed.');
+ }
+
+ $this->provider->import(json_decode($cached ?? '', true, 8, JSON_THROW_ON_ERROR) ?? []);
if ($this->supportedAPIVersion($this->provider->getApiVersion())) {
return $this->provider; // if cache looks valid, we use it
}
@@ -99,8 +104,10 @@ class OCMDiscoveryService implements IOCMDiscoveryService {
$this->cache->set($remote, $body, 60 * 60 * 24);
}
} catch (JsonException|OCMProviderException $e) {
+ $this->cache->set($remote, false, 5 * 60);
throw new OCMProviderException('data returned by remote seems invalid - ' . ($body ?? ''));
} catch (\Exception $e) {
+ $this->cache->set($remote, false, 5 * 60);
$this->logger->warning('error while discovering ocm provider', [
'exception' => $e,
'remote' => $remote
@@ -109,6 +116,7 @@ class OCMDiscoveryService implements IOCMDiscoveryService {
}
if (!$this->supportedAPIVersion($this->provider->getApiVersion())) {
+ $this->cache->set($remote, false, 5 * 60);
throw new OCMProviderException('API version not supported');
}