diff options
author | blizzz <blizzz@arthur-schiwon.de> | 2022-04-14 22:07:45 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-14 22:07:45 +0200 |
commit | e5c6de3c01bf9c1af56cab2f0af2003361413605 (patch) | |
tree | 3bbb7618cebd4b15911b1d04657b6076040b29ee | |
parent | e2f137c2db38e3dc7c34edd6833441aabc8d3700 (diff) | |
parent | 9e3b08924d80fbc2fc2171d3a31d64d2ad817538 (diff) | |
download | nextcloud-server-e5c6de3c01bf9c1af56cab2f0af2003361413605.tar.gz nextcloud-server-e5c6de3c01bf9c1af56cab2f0af2003361413605.zip |
Merge pull request #31634 from nextcloud/backport/31470/stable23
[stable23] improve imagick, bcmath and gmp extension warnings
-rw-r--r-- | apps/settings/lib/Controller/CheckSetupController.php | 35 | ||||
-rw-r--r-- | apps/settings/tests/Controller/CheckSetupControllerTest.php | 12 | ||||
-rw-r--r-- | core/js/setupchecks.js | 18 | ||||
-rw-r--r-- | core/js/tests/specs/setupchecksSpec.js | 154 |
4 files changed, 205 insertions, 14 deletions
diff --git a/apps/settings/lib/Controller/CheckSetupController.php b/apps/settings/lib/Controller/CheckSetupController.php index 4b825c2622f..b9f176f97c5 100644 --- a/apps/settings/lib/Controller/CheckSetupController.php +++ b/apps/settings/lib/Controller/CheckSetupController.php @@ -713,20 +713,6 @@ Raw output $recommendedPHPModules[] = 'intl'; } - if (!extension_loaded('bcmath')) { - $recommendedPHPModules[] = 'bcmath'; - } - - if (!extension_loaded('gmp')) { - $recommendedPHPModules[] = 'gmp'; - } - - if ($this->config->getAppValue('theming', 'enabled', 'no') === 'yes') { - if (!extension_loaded('imagick')) { - $recommendedPHPModules[] = 'imagick'; - } - } - if (!defined('PASSWORD_ARGON2I') && PHP_VERSION_ID >= 70400) { // Installing php-sodium on >=php7.4 will provide PASSWORD_ARGON2I // on previous version argon2 wasn't part of the "standard" extension @@ -738,6 +724,25 @@ Raw output return $recommendedPHPModules; } + protected function isImagickEnabled(): bool { + if ($this->config->getAppValue('theming', 'enabled', 'no') === 'yes') { + if (!extension_loaded('imagick')) { + return false; + } + } + return true; + } + + 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); } @@ -869,6 +874,8 @@ Raw output 'databaseConversionDocumentation' => $this->urlGenerator->linkToDocs('admin-db-conversion'), 'isMemoryLimitSufficient' => $this->memoryInfo->isMemoryLimitSufficient(), 'appDirsWithDifferentOwner' => $this->getAppDirsWithDifferentOwner(), + 'isImagickEnabled' => $this->isImagickEnabled(), + 'areWebauthnExtensionsEnabled' => $this->areWebauthnExtensionsEnabled(), 'recommendedPHPModules' => $this->hasRecommendedPHPModules(), 'pendingBigIntConversionColumns' => $this->hasBigIntConversionPendingColumns(), 'isMysqlUsedWithoutUTF8MB4' => $this->isMysqlUsedWithoutUTF8MB4(), diff --git a/apps/settings/tests/Controller/CheckSetupControllerTest.php b/apps/settings/tests/Controller/CheckSetupControllerTest.php index 4349994570b..8a1e062f58b 100644 --- a/apps/settings/tests/Controller/CheckSetupControllerTest.php +++ b/apps/settings/tests/Controller/CheckSetupControllerTest.php @@ -550,6 +550,16 @@ class CheckSetupControllerTest extends TestCase { $this->checkSetupController ->expects($this->once()) + ->method('isImagickEnabled') + ->willReturn(false); + + $this->checkSetupController + ->expects($this->once()) + ->method('areWebauthnExtensionsEnabled') + ->willReturn(false); + + $this->checkSetupController + ->expects($this->once()) ->method('hasRecommendedPHPModules') ->willReturn([]); @@ -642,6 +652,8 @@ class CheckSetupControllerTest extends TestCase { 'missingColumns' => [], 'isMemoryLimitSufficient' => true, 'appDirsWithDifferentOwner' => [], + 'isImagickEnabled' => false, + 'areWebauthnExtensionsEnabled' => false, 'recommendedPHPModules' => [], 'pendingBigIntConversionColumns' => [], 'isMysqlUsedWithoutUTF8MB4' => false, diff --git a/core/js/setupchecks.js b/core/js/setupchecks.js index fa67528de5d..266f35a9552 100644 --- a/core/js/setupchecks.js +++ b/core/js/setupchecks.js @@ -423,6 +423,24 @@ type: OC.SetupChecks.MESSAGE_TYPE_INFO }) } + if (!data.isImagickEnabled) { + messages.push({ + msg: t( + 'core', + 'The PHP module "imagick" is not enabled although the theming app is. For favicon generation to work correctly, you need to install and enable this module.' + ), + type: OC.SetupChecks.MESSAGE_TYPE_INFO + }) + } + 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.imageMagickLacksSVGSupport) { messages.push({ msg: t( diff --git a/core/js/tests/specs/setupchecksSpec.js b/core/js/tests/specs/setupchecksSpec.js index 5975c875c3b..5914a6f2449 100644 --- a/core/js/tests/specs/setupchecksSpec.js +++ b/core/js/tests/specs/setupchecksSpec.js @@ -249,6 +249,8 @@ describe('OC.SetupChecks tests', function() { }, isMemoryLimitSufficient: true, appDirsWithDifferentOwner: [], + isImagickEnabled: true, + areWebauthnExtensionsEnabled: true, recommendedPHPModules: [], pendingBigIntConversionColumns: [], isMysqlUsedWithoutUTF8MB4: false, @@ -307,6 +309,8 @@ describe('OC.SetupChecks tests', function() { }, isMemoryLimitSufficient: true, appDirsWithDifferentOwner: [], + isImagickEnabled: true, + areWebauthnExtensionsEnabled: true, recommendedPHPModules: [], pendingBigIntConversionColumns: [], isMysqlUsedWithoutUTF8MB4: false, @@ -366,6 +370,8 @@ describe('OC.SetupChecks tests', function() { }, isMemoryLimitSufficient: true, appDirsWithDifferentOwner: [], + isImagickEnabled: true, + areWebauthnExtensionsEnabled: true, recommendedPHPModules: [], pendingBigIntConversionColumns: [], isMysqlUsedWithoutUTF8MB4: false, @@ -423,6 +429,8 @@ describe('OC.SetupChecks tests', function() { }, isMemoryLimitSufficient: true, appDirsWithDifferentOwner: [], + isImagickEnabled: true, + areWebauthnExtensionsEnabled: true, recommendedPHPModules: [], pendingBigIntConversionColumns: [], isMysqlUsedWithoutUTF8MB4: false, @@ -478,6 +486,8 @@ describe('OC.SetupChecks tests', function() { }, isMemoryLimitSufficient: true, appDirsWithDifferentOwner: [], + isImagickEnabled: true, + areWebauthnExtensionsEnabled: true, recommendedPHPModules: [], pendingBigIntConversionColumns: [], isMysqlUsedWithoutUTF8MB4: false, @@ -533,6 +543,8 @@ describe('OC.SetupChecks tests', function() { }, isMemoryLimitSufficient: true, appDirsWithDifferentOwner: [], + isImagickEnabled: true, + areWebauthnExtensionsEnabled: true, recommendedPHPModules: [], pendingBigIntConversionColumns: [], isMysqlUsedWithoutUTF8MB4: false, @@ -590,6 +602,8 @@ describe('OC.SetupChecks tests', function() { appDirsWithDifferentOwner: [ '/some/path' ], + isImagickEnabled: true, + areWebauthnExtensionsEnabled: true, recommendedPHPModules: [], pendingBigIntConversionColumns: [], isMysqlUsedWithoutUTF8MB4: false, @@ -645,6 +659,8 @@ describe('OC.SetupChecks tests', function() { }, isMemoryLimitSufficient: true, appDirsWithDifferentOwner: [], + isImagickEnabled: true, + areWebauthnExtensionsEnabled: true, recommendedPHPModules: [], pendingBigIntConversionColumns: [], isMysqlUsedWithoutUTF8MB4: false, @@ -700,6 +716,8 @@ describe('OC.SetupChecks tests', function() { }, isMemoryLimitSufficient: true, appDirsWithDifferentOwner: [], + isImagickEnabled: true, + areWebauthnExtensionsEnabled: true, recommendedPHPModules: [], pendingBigIntConversionColumns: [], isMysqlUsedWithoutUTF8MB4: false, @@ -755,6 +773,8 @@ describe('OC.SetupChecks tests', function() { }, isMemoryLimitSufficient: false, appDirsWithDifferentOwner: [], + isImagickEnabled: true, + areWebauthnExtensionsEnabled: true, recommendedPHPModules: [], pendingBigIntConversionColumns: [], isMysqlUsedWithoutUTF8MB4: false, @@ -831,6 +851,8 @@ describe('OC.SetupChecks tests', function() { }, isMemoryLimitSufficient: true, appDirsWithDifferentOwner: [], + isImagickEnabled: true, + areWebauthnExtensionsEnabled: true, recommendedPHPModules: [], pendingBigIntConversionColumns: [], isMysqlUsedWithoutUTF8MB4: false, @@ -886,6 +908,8 @@ describe('OC.SetupChecks tests', function() { }, isMemoryLimitSufficient: true, appDirsWithDifferentOwner: [], + isImagickEnabled: true, + areWebauthnExtensionsEnabled: true, recommendedPHPModules: [], pendingBigIntConversionColumns: [], isMysqlUsedWithoutUTF8MB4: false, @@ -941,6 +965,8 @@ describe('OC.SetupChecks tests', function() { }, isMemoryLimitSufficient: true, appDirsWithDifferentOwner: [], + isImagickEnabled: true, + areWebauthnExtensionsEnabled: true, recommendedPHPModules: [], pendingBigIntConversionColumns: [], isMysqlUsedWithoutUTF8MB4: false, @@ -996,6 +1022,8 @@ describe('OC.SetupChecks tests', function() { }, isMemoryLimitSufficient: true, appDirsWithDifferentOwner: [], + isImagickEnabled: true, + areWebauthnExtensionsEnabled: true, recommendedPHPModules: [], pendingBigIntConversionColumns: [], isMysqlUsedWithoutUTF8MB4: true, @@ -1055,6 +1083,8 @@ describe('OC.SetupChecks tests', function() { }, isMemoryLimitSufficient: true, appDirsWithDifferentOwner: [], + isImagickEnabled: true, + areWebauthnExtensionsEnabled: true, recommendedPHPModules: [], pendingBigIntConversionColumns: [], isMysqlUsedWithoutUTF8MB4: false, @@ -1111,6 +1141,8 @@ describe('OC.SetupChecks tests', function() { }, isMemoryLimitSufficient: true, appDirsWithDifferentOwner: [], + isImagickEnabled: true, + areWebauthnExtensionsEnabled: true, recommendedPHPModules: [], pendingBigIntConversionColumns: [], isMysqlUsedWithoutUTF8MB4: false, @@ -1164,6 +1196,8 @@ describe('OC.SetupChecks tests', function() { }, isMemoryLimitSufficient: true, appDirsWithDifferentOwner: [], + isImagickEnabled: true, + areWebauthnExtensionsEnabled: true, recommendedPHPModules: [], pendingBigIntConversionColumns: [], isMysqlUsedWithoutUTF8MB4: false, @@ -1183,6 +1217,122 @@ describe('OC.SetupChecks tests', function() { }); }); + + it('should return an error if imagick is not enabled', function(done) { + var async = OC.SetupChecks.checkSetup(); + + suite.server.requests[0].respond( + 200, + { + 'Content-Type': 'application/json', + }, + JSON.stringify({ + hasFileinfoInstalled: true, + isGetenvServerWorking: true, + isReadOnlyConfig: false, + wasEmailTestSuccessful: true, + hasWorkingFileLocking: true, + hasValidTransactionIsolationLevel: true, + suggestedOverwriteCliURL: '', + isRandomnessSecure: true, + securityDocs: 'https://docs.nextcloud.com/myDocs.html', + isFairUseOfFreePushService: true, + serverHasInternetConnectionProblems: false, + isMemcacheConfigured: true, + forwardedForHeadersWorking: true, + isCorrectMemcachedPHPModuleInstalled: true, + hasPassedCodeIntegrityCheck: true, + OpcacheSetupRecommendations: [], + isSettimelimitAvailable: true, + hasFreeTypeSupport: true, + missingIndexes: [], + missingPrimaryKeys: [], + missingColumns: [], + cronErrors: [], + cronInfo: { + diffInSeconds: 0 + }, + isMemoryLimitSufficient: true, + appDirsWithDifferentOwner: [], + isImagickEnabled: false, + areWebauthnExtensionsEnabled: true, + recommendedPHPModules: [], + pendingBigIntConversionColumns: [], + isMysqlUsedWithoutUTF8MB4: false, + isDefaultPhoneRegionSet: true, + isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true, + reverseProxyGeneratedURL: 'https://server', + temporaryDirectoryWritable: true, + }) + ); + + async.done(function( data, s, x ){ + expect(data).toEqual([{ + msg: 'The PHP module "imagick" is not enabled although the theming app is. For favicon generation to work correctly, you need to install and enable this module.', + type: OC.SetupChecks.MESSAGE_TYPE_INFO + }]); + done(); + }); + }); + + + 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({ + hasFileinfoInstalled: true, + isGetenvServerWorking: true, + isReadOnlyConfig: false, + wasEmailTestSuccessful: true, + hasWorkingFileLocking: true, + hasValidTransactionIsolationLevel: true, + suggestedOverwriteCliURL: '', + isRandomnessSecure: true, + securityDocs: 'https://docs.nextcloud.com/myDocs.html', + isFairUseOfFreePushService: true, + serverHasInternetConnectionProblems: false, + isMemcacheConfigured: true, + forwardedForHeadersWorking: true, + isCorrectMemcachedPHPModuleInstalled: true, + hasPassedCodeIntegrityCheck: true, + OpcacheSetupRecommendations: [], + isSettimelimitAvailable: true, + hasFreeTypeSupport: true, + missingIndexes: [], + missingPrimaryKeys: [], + missingColumns: [], + cronErrors: [], + cronInfo: { + diffInSeconds: 0 + }, + isMemoryLimitSufficient: true, + appDirsWithDifferentOwner: [], + isImagickEnabled: true, + areWebauthnExtensionsEnabled: false, + recommendedPHPModules: [], + pendingBigIntConversionColumns: [], + isMysqlUsedWithoutUTF8MB4: false, + isDefaultPhoneRegionSet: true, + isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true, + reverseProxyGeneratedURL: 'https://server', + temporaryDirectoryWritable: true, + }) + ); + + 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(); @@ -1219,6 +1369,8 @@ describe('OC.SetupChecks tests', function() { }, isMemoryLimitSufficient: true, appDirsWithDifferentOwner: [], + isImagickEnabled: true, + areWebauthnExtensionsEnabled: true, recommendedPHPModules: [], pendingBigIntConversionColumns: [], isMysqlUsedWithoutUTF8MB4: false, @@ -1274,6 +1426,8 @@ describe('OC.SetupChecks tests', function() { }, isMemoryLimitSufficient: true, appDirsWithDifferentOwner: [], + isImagickEnabled: true, + areWebauthnExtensionsEnabled: true, recommendedPHPModules: [], pendingBigIntConversionColumns: [], isMysqlUsedWithoutUTF8MB4: false, |