Skip to content

Commit 8ada5ae

Browse files
nickvergessenbackportbot[bot]
authored andcommitted
fix(setupcheck): Make the Memcache setupcheck use the cache
Signed-off-by: Joas Schilling <coding@schilljs.com> [skip ci]
1 parent fbfe307 commit 8ada5ae

1 file changed

Lines changed: 36 additions & 0 deletions

File tree

apps/settings/lib/SetupChecks/MemcacheConfigured.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public function __construct(
3636
private IL10N $l10n,
3737
private IConfig $config,
3838
private IURLGenerator $urlGenerator,
39+
private ICacheFactory $cacheFactory,
3940
) {
4041
}
4142

@@ -72,6 +73,41 @@ public function run(): SetupResult {
7273
$this->urlGenerator->linkToDocs('admin-performance')
7374
);
7475
}
76+
77+
if ($this->cacheFactory->isLocalCacheAvailable()) {
78+
$random = random_bytes(64);
79+
$local = $this->cacheFactory->createLocal('setupcheck.local');
80+
try {
81+
$local->set('test', $random);
82+
$local2 = $this->cacheFactory->createLocal('setupcheck.local');
83+
$actual = $local2->get('test');
84+
$local->remove('test');
85+
} catch (\Throwable) {
86+
$actual = null;
87+
}
88+
89+
if ($actual !== $random) {
90+
return SetupResult::error($this->l10n->t('Failed to write and read a value from local cache.'));
91+
}
92+
}
93+
94+
if ($this->cacheFactory->isAvailable()) {
95+
$random = random_bytes(64);
96+
$distributed = $this->cacheFactory->createDistributed('setupcheck');
97+
try {
98+
$distributed->set('test', $random);
99+
$distributed2 = $this->cacheFactory->createDistributed('setupcheck');
100+
$actual = $distributed2->get('test');
101+
$distributed->remove('test');
102+
} catch (\Throwable) {
103+
$actual = null;
104+
}
105+
106+
if ($actual !== $random) {
107+
return SetupResult::error($this->l10n->t('Failed to write and read a value from distributed cache.'));
108+
}
109+
}
110+
75111
return SetupResult::success($this->l10n->t('Configured'));
76112
}
77113
}

0 commit comments

Comments
 (0)