From c103133272f1182eee2f4b00469e56687a86bedb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Szymon=20K=C5=82os?= Date: Tue, 27 Apr 2021 16:39:55 +0200 Subject: Don't cache empty capabilities MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When caching is configured and request to fetch the capabilities fails - don't cache the empty result for a long time. This way we will avoid persisting error: "Collabora Online is not setup yet". To test bug: 1. use Nextcloud with caching & richdocuments 2. restart apache and stop Collabora Online server 3. open Nextcloud and try to open any document you will get "Collabora Online is not setup yet" error 4. start Collabora Online server 5. refresh page and try to open file again before: error persisted until admin changed richdocuments configuration after: file is opened with Collabora Online in 60s from start Signed-off-by: Szymon Kłos --- lib/Service/CapabilitiesService.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/Service/CapabilitiesService.php b/lib/Service/CapabilitiesService.php index 981b3640..58115795 100644 --- a/lib/Service/CapabilitiesService.php +++ b/lib/Service/CapabilitiesService.php @@ -113,6 +113,10 @@ class CapabilitiesService { } $this->capabilities = $capabilities; - $this->cache->set('capabilities', $capabilities, 3600); + $ttl = 3600; + if (count($capabilities) === 0) + $ttl = 60; + + $this->cache->set('capabilities', $capabilities, $ttl); } } -- cgit v1.2.3