aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2024-12-02 09:02:22 +0100
committerJoas Schilling <coding@schilljs.com>2024-12-19 15:35:04 +0100
commitf12b81534aa69193ca9e1cc59b302dc022001afe (patch)
tree104c663eeb61fa2ab883ba7e1c2623e7c4fa65cc
parent0c32d3838326508d10f291b4046ebc8270ec0b4a (diff)
downloadnextcloud-server-backport/49588/stable30.tar.gz
nextcloud-server-backport/49588/stable30.zip
fix(setupcheck): Make the Memcache setupcheck use the cachebackport/49588/stable30
Signed-off-by: Joas Schilling <coding@schilljs.com>
-rw-r--r--apps/settings/lib/SetupChecks/MemcacheConfigured.php37
1 files changed, 37 insertions, 0 deletions
diff --git a/apps/settings/lib/SetupChecks/MemcacheConfigured.php b/apps/settings/lib/SetupChecks/MemcacheConfigured.php
index 03cdc91cb5f..c5acf5b5e34 100644
--- a/apps/settings/lib/SetupChecks/MemcacheConfigured.php
+++ b/apps/settings/lib/SetupChecks/MemcacheConfigured.php
@@ -8,6 +8,7 @@ declare(strict_types=1);
*/
namespace OCA\Settings\SetupChecks;
+use OCP\ICacheFactory;
use OCP\IConfig;
use OCP\IL10N;
use OCP\IURLGenerator;
@@ -19,6 +20,7 @@ class MemcacheConfigured implements ISetupCheck {
private IL10N $l10n,
private IConfig $config,
private IURLGenerator $urlGenerator,
+ private ICacheFactory $cacheFactory,
) {
}
@@ -55,6 +57,41 @@ class MemcacheConfigured implements ISetupCheck {
$this->urlGenerator->linkToDocs('admin-performance')
);
}
+
+ if ($this->cacheFactory->isLocalCacheAvailable()) {
+ $random = random_bytes(64);
+ $local = $this->cacheFactory->createLocal('setupcheck.local');
+ try {
+ $local->set('test', $random);
+ $local2 = $this->cacheFactory->createLocal('setupcheck.local');
+ $actual = $local2->get('test');
+ $local->remove('test');
+ } catch (\Throwable) {
+ $actual = null;
+ }
+
+ if ($actual !== $random) {
+ return SetupResult::error($this->l10n->t('Failed to write and read a value from local cache.'));
+ }
+ }
+
+ if ($this->cacheFactory->isAvailable()) {
+ $random = random_bytes(64);
+ $distributed = $this->cacheFactory->createDistributed('setupcheck');
+ try {
+ $distributed->set('test', $random);
+ $distributed2 = $this->cacheFactory->createDistributed('setupcheck');
+ $actual = $distributed2->get('test');
+ $distributed->remove('test');
+ } catch (\Throwable) {
+ $actual = null;
+ }
+
+ if ($actual !== $random) {
+ return SetupResult::error($this->l10n->t('Failed to write and read a value from distributed cache.'));
+ }
+ }
+
return SetupResult::success($this->l10n->t('Configured'));
}
}