Skip to content

Commit e5c6de3

Browse files
authored
Merge pull request #31634 from nextcloud/backport/31470/stable23
[stable23] improve imagick, bcmath and gmp extension warnings
2 parents e2f137c + 9e3b089 commit e5c6de3

4 files changed

Lines changed: 205 additions & 14 deletions

File tree

apps/settings/lib/Controller/CheckSetupController.php

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -713,20 +713,6 @@ protected function hasRecommendedPHPModules(): array {
713713
$recommendedPHPModules[] = 'intl';
714714
}
715715

716-
if (!extension_loaded('bcmath')) {
717-
$recommendedPHPModules[] = 'bcmath';
718-
}
719-
720-
if (!extension_loaded('gmp')) {
721-
$recommendedPHPModules[] = 'gmp';
722-
}
723-
724-
if ($this->config->getAppValue('theming', 'enabled', 'no') === 'yes') {
725-
if (!extension_loaded('imagick')) {
726-
$recommendedPHPModules[] = 'imagick';
727-
}
728-
}
729-
730716
if (!defined('PASSWORD_ARGON2I') && PHP_VERSION_ID >= 70400) {
731717
// Installing php-sodium on >=php7.4 will provide PASSWORD_ARGON2I
732718
// on previous version argon2 wasn't part of the "standard" extension
@@ -738,6 +724,25 @@ protected function hasRecommendedPHPModules(): array {
738724
return $recommendedPHPModules;
739725
}
740726

727+
protected function isImagickEnabled(): bool {
728+
if ($this->config->getAppValue('theming', 'enabled', 'no') === 'yes') {
729+
if (!extension_loaded('imagick')) {
730+
return false;
731+
}
732+
}
733+
return true;
734+
}
735+
736+
protected function areWebauthnExtensionsEnabled(): bool {
737+
if (!extension_loaded('bcmath')) {
738+
return false;
739+
}
740+
if (!extension_loaded('gmp')) {
741+
return false;
742+
}
743+
return true;
744+
}
745+
741746
protected function isMysqlUsedWithoutUTF8MB4(): bool {
742747
return ($this->config->getSystemValue('dbtype', 'sqlite') === 'mysql') && ($this->config->getSystemValue('mysql.utf8mb4', false) === false);
743748
}
@@ -869,6 +874,8 @@ public function check() {
869874
'databaseConversionDocumentation' => $this->urlGenerator->linkToDocs('admin-db-conversion'),
870875
'isMemoryLimitSufficient' => $this->memoryInfo->isMemoryLimitSufficient(),
871876
'appDirsWithDifferentOwner' => $this->getAppDirsWithDifferentOwner(),
877+
'isImagickEnabled' => $this->isImagickEnabled(),
878+
'areWebauthnExtensionsEnabled' => $this->areWebauthnExtensionsEnabled(),
872879
'recommendedPHPModules' => $this->hasRecommendedPHPModules(),
873880
'pendingBigIntConversionColumns' => $this->hasBigIntConversionPendingColumns(),
874881
'isMysqlUsedWithoutUTF8MB4' => $this->isMysqlUsedWithoutUTF8MB4(),

apps/settings/tests/Controller/CheckSetupControllerTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,16 @@ public function testCheck() {
548548
->method('getAppDirsWithDifferentOwner')
549549
->willReturn([]);
550550

551+
$this->checkSetupController
552+
->expects($this->once())
553+
->method('isImagickEnabled')
554+
->willReturn(false);
555+
556+
$this->checkSetupController
557+
->expects($this->once())
558+
->method('areWebauthnExtensionsEnabled')
559+
->willReturn(false);
560+
551561
$this->checkSetupController
552562
->expects($this->once())
553563
->method('hasRecommendedPHPModules')
@@ -642,6 +652,8 @@ public function testCheck() {
642652
'missingColumns' => [],
643653
'isMemoryLimitSufficient' => true,
644654
'appDirsWithDifferentOwner' => [],
655+
'isImagickEnabled' => false,
656+
'areWebauthnExtensionsEnabled' => false,
645657
'recommendedPHPModules' => [],
646658
'pendingBigIntConversionColumns' => [],
647659
'isMysqlUsedWithoutUTF8MB4' => false,

core/js/setupchecks.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,24 @@
423423
type: OC.SetupChecks.MESSAGE_TYPE_INFO
424424
})
425425
}
426+
if (!data.isImagickEnabled) {
427+
messages.push({
428+
msg: t(
429+
'core',
430+
'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.'
431+
),
432+
type: OC.SetupChecks.MESSAGE_TYPE_INFO
433+
})
434+
}
435+
if (!data.areWebauthnExtensionsEnabled) {
436+
messages.push({
437+
msg: t(
438+
'core',
439+
'The PHP modules "gmp" and/or "bcmath" are not enabled. If you use WebAuthn passwordless authentication, these modules are required.'
440+
),
441+
type: OC.SetupChecks.MESSAGE_TYPE_INFO
442+
})
443+
}
426444
if (data.imageMagickLacksSVGSupport) {
427445
messages.push({
428446
msg: t(

0 commit comments

Comments
 (0)