From 5ad549a72f54ce36bc9cb78e4dbdea657cfd3adf Mon Sep 17 00:00:00 2001 From: Côme Chilliet Date: Mon, 15 Jan 2024 16:45:19 +0100 Subject: Migrate memcached PHP module setup check to new API MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Merged it with the other existing memcache setup check as it fits Signed-off-by: Côme Chilliet --- .../lib/Controller/CheckSetupController.php | 19 ------------------- .../lib/SetupChecks/MemcacheConfigured.php | 22 +++++++++++++++++++--- .../tests/Controller/CheckSetupControllerTest.php | 1 - 3 files changed, 19 insertions(+), 23 deletions(-) (limited to 'apps') 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 @@ -123,24 +123,6 @@ class CheckSetupController extends Controller { return $this->manager->isFairUseOfFreePushService(); } - /** - * 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. * @@ -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, -- cgit v1.2.3