aboutsummaryrefslogtreecommitdiffstats
path: root/apps/settings
diff options
context:
space:
mode:
authorFerdinand Thiessen <opensource@fthiessen.de>2024-01-18 12:23:02 +0100
committerGitHub <noreply@github.com>2024-01-18 12:23:02 +0100
commit1334055ab8d07f2a02806dc68235413b72903218 (patch)
tree288d8df30381e82438c3cdcd76268af5f52c33a5 /apps/settings
parent24dc742f877aa3ec4c5b0c023cab3e496bbfca9d (diff)
parent5ad549a72f54ce36bc9cb78e4dbdea657cfd3adf (diff)
downloadnextcloud-server-1334055ab8d07f2a02806dc68235413b72903218.tar.gz
nextcloud-server-1334055ab8d07f2a02806dc68235413b72903218.zip
Merge pull request #42812 from nextcloud/enh/migrate-memcached-setupcheck
Migrate memcached PHP module setup check to new API
Diffstat (limited to 'apps/settings')
-rw-r--r--apps/settings/lib/Controller/CheckSetupController.php19
-rw-r--r--apps/settings/lib/SetupChecks/MemcacheConfigured.php22
-rw-r--r--apps/settings/tests/Controller/CheckSetupControllerTest.php1
3 files changed, 19 insertions, 23 deletions
diff --git a/apps/settings/lib/Controller/CheckSetupController.php b/apps/settings/lib/Controller/CheckSetupController.php
index 8897548a977..c94bc56c4ba 100644
--- a/apps/settings/lib/Controller/CheckSetupController.php
+++ b/apps/settings/lib/Controller/CheckSetupController.php
@@ -124,24 +124,6 @@ class CheckSetupController extends Controller {
}
/**
- * Checks if the correct memcache module for PHP is installed. Only
- * fails if memcached is configured and the working module is not installed.
- *
- * @return bool
- */
- private function isCorrectMemcachedPHPModuleInstalled() {
- $memcacheDistributedClass = $this->config->getSystemValue('memcache.distributed', null);
- if ($memcacheDistributedClass === null || ltrim($memcacheDistributedClass, '\\') !== \OC\Memcache\Memcached::class) {
- return true;
- }
-
- // there are two different memcache modules for PHP
- // we only support memcached and not memcache
- // https://code.google.com/p/memcached/wiki/PHPClientComparison
- return !(!extension_loaded('memcached') && extension_loaded('memcache'));
- }
-
- /**
* Checks if set_time_limit is not disabled.
*
* @return bool
@@ -293,7 +275,6 @@ Raw output
[
'isFairUseOfFreePushService' => $this->isFairUseOfFreePushService(),
'reverseProxyDocs' => $this->urlGenerator->linkToDocs('admin-reverse-proxy'),
- 'isCorrectMemcachedPHPModuleInstalled' => $this->isCorrectMemcachedPHPModuleInstalled(),
'isSettimelimitAvailable' => $this->isSettimelimitAvailable(),
'areWebauthnExtensionsEnabled' => $this->areWebauthnExtensionsEnabled(),
'isMysqlUsedWithoutUTF8MB4' => $this->isMysqlUsedWithoutUTF8MB4(),
diff --git a/apps/settings/lib/SetupChecks/MemcacheConfigured.php b/apps/settings/lib/SetupChecks/MemcacheConfigured.php
index 2cde18a25df..1afe9cb879c 100644
--- a/apps/settings/lib/SetupChecks/MemcacheConfigured.php
+++ b/apps/settings/lib/SetupChecks/MemcacheConfigured.php
@@ -48,13 +48,29 @@ class MemcacheConfigured implements ISetupCheck {
}
public function run(): SetupResult {
- if ($this->config->getSystemValue('memcache.local', null) !== null) {
- return SetupResult::success($this->l10n->t('Configured'));
- } else {
+ $memcacheDistributedClass = $this->config->getSystemValue('memcache.distributed', null);
+ $memcacheLockingClass = $this->config->getSystemValue('memcache.locking', null);
+ $memcacheLocalClass = $this->config->getSystemValue('memcache.local', null);
+ $caches = array_filter([$memcacheDistributedClass,$memcacheLockingClass,$memcacheLocalClass]);
+ if (in_array(\OC\Memcache\Memcached::class, array_map(fn (string $class) => ltrim($class, '\\'), $caches))) {
+ if (extension_loaded('memcache')) {
+ return SetupResult::warning(
+ $this->l10n->t('Memcached is configured as distributed cache, but the wrong PHP module "memcache" is installed. \\OC\\Memcache\\Memcached only supports "memcached" and not "memcache".'),
+ 'https://code.google.com/p/memcached/wiki/PHPClientComparison'
+ );
+ }
+ if (!extension_loaded('memcached')) {
+ return SetupResult::warning(
+ $this->l10n->t('Memcached is configured as distributed cache, but the PHP module "memcached" is not installed.')
+ );
+ }
+ }
+ if ($memcacheLocalClass === null) {
return SetupResult::info(
$this->l10n->t('No memory cache has been configured. To enhance performance, please configure a memcache, if available.'),
$this->urlGenerator->linkToDocs('admin-performance')
);
}
+ return SetupResult::success($this->l10n->t('Configured'));
}
}
diff --git a/apps/settings/tests/Controller/CheckSetupControllerTest.php b/apps/settings/tests/Controller/CheckSetupControllerTest.php
index 3bec435bd6a..deec0e6aedd 100644
--- a/apps/settings/tests/Controller/CheckSetupControllerTest.php
+++ b/apps/settings/tests/Controller/CheckSetupControllerTest.php
@@ -192,7 +192,6 @@ class CheckSetupControllerTest extends TestCase {
$expected = new DataResponse(
[
'reverseProxyDocs' => 'reverse-proxy-doc-link',
- 'isCorrectMemcachedPHPModuleInstalled' => true,
'isSettimelimitAvailable' => true,
'areWebauthnExtensionsEnabled' => false,
'isMysqlUsedWithoutUTF8MB4' => false,