From ca3e1a531a337d9ed0c6ea35536354dec19e6526 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= Date: Tue, 16 Jan 2024 10:03:22 +0100 Subject: [PATCH 1/4] Merge gmp and bcmath module checks with the existing PHP modules setup check MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also add description for why each module is recommended Signed-off-by: Côme Chilliet --- .../lib/Controller/CheckSetupController.php | 11 ----- apps/settings/lib/SetupChecks/PhpModules.php | 21 ++++++++- .../Controller/CheckSetupControllerTest.php | 7 --- core/js/setupchecks.js | 9 ---- core/js/tests/specs/setupchecksSpec.js | 47 ------------------- 5 files changed, 20 insertions(+), 75 deletions(-) diff --git a/apps/settings/lib/Controller/CheckSetupController.php b/apps/settings/lib/Controller/CheckSetupController.php index 074625e02c07d..21161be7cf2ec 100644 --- a/apps/settings/lib/Controller/CheckSetupController.php +++ b/apps/settings/lib/Controller/CheckSetupController.php @@ -202,16 +202,6 @@ private function isTemporaryDirectoryWritable(): bool { return false; } - protected function areWebauthnExtensionsEnabled(): bool { - if (!extension_loaded('bcmath')) { - return false; - } - if (!extension_loaded('gmp')) { - return false; - } - return true; - } - protected function isMysqlUsedWithoutUTF8MB4(): bool { return ($this->config->getSystemValue('dbtype', 'sqlite') === 'mysql') && ($this->config->getSystemValue('mysql.utf8mb4', false) === false); } @@ -261,7 +251,6 @@ public function check() { [ 'isFairUseOfFreePushService' => $this->isFairUseOfFreePushService(), 'reverseProxyDocs' => $this->urlGenerator->linkToDocs('admin-reverse-proxy'), - 'areWebauthnExtensionsEnabled' => $this->areWebauthnExtensionsEnabled(), 'isMysqlUsedWithoutUTF8MB4' => $this->isMysqlUsedWithoutUTF8MB4(), 'isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed' => $this->isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed(), 'reverseProxyGeneratedURL' => $this->urlGenerator->getAbsoluteURL('index.php'), diff --git a/apps/settings/lib/SetupChecks/PhpModules.php b/apps/settings/lib/SetupChecks/PhpModules.php index bacf70eb9c942..e1084d68d5a78 100644 --- a/apps/settings/lib/SetupChecks/PhpModules.php +++ b/apps/settings/lib/SetupChecks/PhpModules.php @@ -69,6 +69,18 @@ public function getCategory(): string { return 'php'; } + protected function getRecommendedModuleDescription(string $module): string { + return match($module) { + 'bz2' => $this->l10n->t('required for extraction of apps compressed as bz2'), + 'intl' => $this->l10n->t('increases language translation performance and fixes sorting of non-ASCII characters'), + 'sodium' => $this->l10n->t('for Argon2 for password hashing'), + 'bcmath' => $this->l10n->t('for WebAuthn passwordless login'), + 'gmp' => $this->l10n->t('for WebAuthn passwordless login, and SFTP storage'), + 'exif' => $this->l10n->t('for image rotation in pictures app'), + default => '', + }; + } + public function run(): SetupResult { $missingRecommendedModules = $this->getMissingModules(self::RECOMMENDED_MODULES); $missingRequiredModules = $this->getMissingModules(self::REQUIRED_MODULES); @@ -78,8 +90,15 @@ public function run(): SetupResult { $this->urlGenerator->linkToDocs('admin-php-modules') ); } elseif (!empty($missingRecommendedModules)) { + $moduleList = implode( + "\n", + array_map( + fn (string $module) => '- '.$module.' '.$this->getRecommendedModuleDescription($module), + $missingRecommendedModules + ) + ); return SetupResult::info( - $this->l10n->t('This instance is missing some recommended PHP modules. For improved performance and better compatibility it is highly recommended to install them: %s.', implode(', ', $missingRecommendedModules)), + $this->l10n->t("This instance is missing some recommended PHP modules. For improved performance and better compatibility it is highly recommended to install them:\n%s", $moduleList), $this->urlGenerator->linkToDocs('admin-php-modules') ); } else { diff --git a/apps/settings/tests/Controller/CheckSetupControllerTest.php b/apps/settings/tests/Controller/CheckSetupControllerTest.php index f135e075279cd..bad15a721919f 100644 --- a/apps/settings/tests/Controller/CheckSetupControllerTest.php +++ b/apps/settings/tests/Controller/CheckSetupControllerTest.php @@ -118,7 +118,6 @@ protected function setUp(): void { 'getCurlVersion', 'isPhpOutdated', 'isPHPMailerUsed', - 'areWebauthnExtensionsEnabled', 'isMysqlUsedWithoutUTF8MB4', 'isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed', ])->getMock(); @@ -143,11 +142,6 @@ public function testCheck() { $this->request->expects($this->never()) ->method('getHeader'); - $this->checkSetupController - ->expects($this->once()) - ->method('areWebauthnExtensionsEnabled') - ->willReturn(false); - $this->checkSetupController ->expects($this->once()) ->method('isMysqlUsedWithoutUTF8MB4') @@ -192,7 +186,6 @@ public function testCheck() { $expected = new DataResponse( [ 'reverseProxyDocs' => 'reverse-proxy-doc-link', - 'areWebauthnExtensionsEnabled' => false, 'isMysqlUsedWithoutUTF8MB4' => false, 'isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed' => true, 'reverseProxyGeneratedURL' => 'https://server/index.php', diff --git a/core/js/setupchecks.js b/core/js/setupchecks.js index 678cb02bfa271..0be5ceafd36ea 100644 --- a/core/js/setupchecks.js +++ b/core/js/setupchecks.js @@ -188,15 +188,6 @@ type: OC.SetupChecks.MESSAGE_TYPE_ERROR }); } - if (!data.areWebauthnExtensionsEnabled) { - messages.push({ - msg: t( - 'core', - 'The PHP modules "gmp" and/or "bcmath" are not enabled. If you use WebAuthn passwordless authentication, these modules are required.' - ), - type: OC.SetupChecks.MESSAGE_TYPE_INFO - }) - } if (data.isMysqlUsedWithoutUTF8MB4) { messages.push({ diff --git a/core/js/tests/specs/setupchecksSpec.js b/core/js/tests/specs/setupchecksSpec.js index 857156f143720..68325123efbd7 100644 --- a/core/js/tests/specs/setupchecksSpec.js +++ b/core/js/tests/specs/setupchecksSpec.js @@ -224,7 +224,6 @@ describe('OC.SetupChecks tests', function() { }, JSON.stringify({ isFairUseOfFreePushService: true, - areWebauthnExtensionsEnabled: true, isMysqlUsedWithoutUTF8MB4: false, isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true, reverseProxyGeneratedURL: 'https://server', @@ -262,7 +261,6 @@ describe('OC.SetupChecks tests', function() { }, JSON.stringify({ isFairUseOfFreePushService: true, - areWebauthnExtensionsEnabled: true, isMysqlUsedWithoutUTF8MB4: false, isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true, reverseProxyGeneratedURL: 'https://server', @@ -300,7 +298,6 @@ describe('OC.SetupChecks tests', function() { }, JSON.stringify({ isFairUseOfFreePushService: true, - areWebauthnExtensionsEnabled: true, isMysqlUsedWithoutUTF8MB4: false, isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true, reverseProxyGeneratedURL: 'https://server', @@ -339,7 +336,6 @@ describe('OC.SetupChecks tests', function() { JSON.stringify({ isFairUseOfFreePushService: true, reverseProxyDocs: 'https://docs.nextcloud.com/foo/bar.html', - areWebauthnExtensionsEnabled: true, isMysqlUsedWithoutUTF8MB4: false, isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true, reverseProxyGeneratedURL: 'https://server', @@ -407,7 +403,6 @@ describe('OC.SetupChecks tests', function() { }, JSON.stringify({ isFairUseOfFreePushService: true, - areWebauthnExtensionsEnabled: true, isMysqlUsedWithoutUTF8MB4: false, isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true, reverseProxyGeneratedURL: 'https://server', @@ -450,7 +445,6 @@ describe('OC.SetupChecks tests', function() { }, JSON.stringify({ isFairUseOfFreePushService: true, - areWebauthnExtensionsEnabled: true, isMysqlUsedWithoutUTF8MB4: true, isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true, reverseProxyGeneratedURL: 'https://server', @@ -490,7 +484,6 @@ describe('OC.SetupChecks tests', function() { }, JSON.stringify({ isFairUseOfFreePushService: true, - areWebauthnExtensionsEnabled: true, isMysqlUsedWithoutUTF8MB4: false, isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true, reverseProxyDocs: 'https://docs.nextcloud.com/foo/bar.html', @@ -527,7 +520,6 @@ describe('OC.SetupChecks tests', function() { }, JSON.stringify({ isFairUseOfFreePushService: true, - areWebauthnExtensionsEnabled: true, isMysqlUsedWithoutUTF8MB4: false, isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true, reverseProxyDocs: 'https://docs.nextcloud.com/foo/bar.html', @@ -561,7 +553,6 @@ describe('OC.SetupChecks tests', function() { }, JSON.stringify({ isFairUseOfFreePushService: true, - areWebauthnExtensionsEnabled: true, isMysqlUsedWithoutUTF8MB4: false, isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: false, reverseProxyGeneratedURL: 'https://server', @@ -587,42 +578,6 @@ describe('OC.SetupChecks tests', function() { }); }); - it('should return an error if gmp or bcmath are not enabled', function(done) { - var async = OC.SetupChecks.checkSetup(); - - suite.server.requests[0].respond( - 200, - { - 'Content-Type': 'application/json', - }, - JSON.stringify({ - isFairUseOfFreePushService: true, - areWebauthnExtensionsEnabled: false, - isMysqlUsedWithoutUTF8MB4: false, - isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true, - reverseProxyGeneratedURL: 'https://server', - temporaryDirectoryWritable: true, - generic: { - network: { - "Internet connectivity": { - severity: "success", - description: null, - linkToDoc: null - } - }, - }, - }) - ); - - async.done(function( data, s, x ){ - expect(data).toEqual([{ - msg: 'The PHP modules "gmp" and/or "bcmath" are not enabled. If you use WebAuthn passwordless authentication, these modules are required.', - type: OC.SetupChecks.MESSAGE_TYPE_INFO - }]); - done(); - }); - }); - it('should return an info if there is no default phone region', function(done) { var async = OC.SetupChecks.checkSetup(); @@ -633,7 +588,6 @@ describe('OC.SetupChecks tests', function() { }, JSON.stringify({ isFairUseOfFreePushService: true, - areWebauthnExtensionsEnabled: true, isMysqlUsedWithoutUTF8MB4: false, isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true, reverseProxyGeneratedURL: 'https://server', @@ -676,7 +630,6 @@ describe('OC.SetupChecks tests', function() { }, JSON.stringify({ isFairUseOfFreePushService: true, - areWebauthnExtensionsEnabled: true, isMysqlUsedWithoutUTF8MB4: false, isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true, reverseProxyGeneratedURL: 'https://server', From 4c342163051201e3f8861609bf615d018bc8a499 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= Date: Thu, 18 Jan 2024 14:57:13 +0100 Subject: [PATCH 2/4] Fix description for exif PHP module MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Côme Chilliet --- apps/settings/lib/SetupChecks/PhpModules.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/settings/lib/SetupChecks/PhpModules.php b/apps/settings/lib/SetupChecks/PhpModules.php index e1084d68d5a78..d6bd8bc68e9f5 100644 --- a/apps/settings/lib/SetupChecks/PhpModules.php +++ b/apps/settings/lib/SetupChecks/PhpModules.php @@ -76,7 +76,7 @@ protected function getRecommendedModuleDescription(string $module): string { 'sodium' => $this->l10n->t('for Argon2 for password hashing'), 'bcmath' => $this->l10n->t('for WebAuthn passwordless login'), 'gmp' => $this->l10n->t('for WebAuthn passwordless login, and SFTP storage'), - 'exif' => $this->l10n->t('for image rotation in pictures app'), + 'exif' => $this->l10n->t('for picture rotation in server and metadata extraction in the Photos app'), default => '', }; } From f13b2fb103e4d2aebbd4083c4b56d44a0f752c28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= Date: Mon, 22 Jan 2024 15:08:59 +0100 Subject: [PATCH 3/4] Add missing recommended modules gmp and bcmath MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Côme Chilliet --- apps/settings/lib/SetupChecks/PhpModules.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/apps/settings/lib/SetupChecks/PhpModules.php b/apps/settings/lib/SetupChecks/PhpModules.php index d6bd8bc68e9f5..1f22c3a79964d 100644 --- a/apps/settings/lib/SetupChecks/PhpModules.php +++ b/apps/settings/lib/SetupChecks/PhpModules.php @@ -49,7 +49,9 @@ class PhpModules implements ISetupCheck { 'zlib', ]; protected const RECOMMENDED_MODULES = [ + 'bcmath', 'exif', + 'gmp', 'intl', 'sodium', 'sysvsem', From c43144fc7d231660f9f759ee5fa908933204d8ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= Date: Mon, 22 Jan 2024 15:56:40 +0100 Subject: [PATCH 4/4] Remove bz2 leftover description MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Côme Chilliet --- apps/settings/lib/SetupChecks/PhpModules.php | 1 - 1 file changed, 1 deletion(-) diff --git a/apps/settings/lib/SetupChecks/PhpModules.php b/apps/settings/lib/SetupChecks/PhpModules.php index 1f22c3a79964d..9a6ddadbb1bb0 100644 --- a/apps/settings/lib/SetupChecks/PhpModules.php +++ b/apps/settings/lib/SetupChecks/PhpModules.php @@ -73,7 +73,6 @@ public function getCategory(): string { protected function getRecommendedModuleDescription(string $module): string { return match($module) { - 'bz2' => $this->l10n->t('required for extraction of apps compressed as bz2'), 'intl' => $this->l10n->t('increases language translation performance and fixes sorting of non-ASCII characters'), 'sodium' => $this->l10n->t('for Argon2 for password hashing'), 'bcmath' => $this->l10n->t('for WebAuthn passwordless login'),