mirror of
https://github.com/nextcloud/server.git
synced 2026-02-18 18:28:50 -05:00
Migrate PHP imagick module check to new SetupCheck API
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
This commit is contained in:
parent
744720b443
commit
d1f2add10c
8 changed files with 67 additions and 98 deletions
|
|
@ -342,15 +342,6 @@ Raw output
|
|||
return false;
|
||||
}
|
||||
|
||||
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;
|
||||
|
|
@ -401,10 +392,6 @@ Raw output
|
|||
return false;
|
||||
}
|
||||
|
||||
protected function imageMagickLacksSVGSupport(): bool {
|
||||
return extension_loaded('imagick') && count(\Imagick::queryFormats('SVG')) === 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return DataResponse
|
||||
* @AuthorizedAdminSetting(settings=OCA\Settings\Settings\Admin\Overview)
|
||||
|
|
@ -422,12 +409,10 @@ Raw output
|
|||
'hasPassedCodeIntegrityCheck' => $this->checker->hasPassedCheck(),
|
||||
'codeIntegrityCheckerDocumentation' => $this->urlGenerator->linkToDocs('admin-code-integrity'),
|
||||
'isSettimelimitAvailable' => $this->isSettimelimitAvailable(),
|
||||
'isImagickEnabled' => $this->isImagickEnabled(),
|
||||
'areWebauthnExtensionsEnabled' => $this->areWebauthnExtensionsEnabled(),
|
||||
'isMysqlUsedWithoutUTF8MB4' => $this->isMysqlUsedWithoutUTF8MB4(),
|
||||
'isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed' => $this->isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed(),
|
||||
'reverseProxyGeneratedURL' => $this->urlGenerator->getAbsoluteURL('index.php'),
|
||||
'imageMagickLacksSVGSupport' => $this->imageMagickLacksSVGSupport(),
|
||||
'temporaryDirectoryWritable' => $this->isTemporaryDirectoryWritable(),
|
||||
'generic' => $this->setupCheckManager->runAll(),
|
||||
]
|
||||
|
|
|
|||
|
|
@ -139,7 +139,6 @@ class CheckSetupControllerTest extends TestCase {
|
|||
'getCurlVersion',
|
||||
'isPhpOutdated',
|
||||
'isPHPMailerUsed',
|
||||
'isImagickEnabled',
|
||||
'areWebauthnExtensionsEnabled',
|
||||
'isMysqlUsedWithoutUTF8MB4',
|
||||
'isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed',
|
||||
|
|
@ -197,11 +196,6 @@ class CheckSetupControllerTest extends TestCase {
|
|||
->method('hasPassedCheck')
|
||||
->willReturn(true);
|
||||
|
||||
$this->checkSetupController
|
||||
->expects($this->once())
|
||||
->method('isImagickEnabled')
|
||||
->willReturn(false);
|
||||
|
||||
$this->checkSetupController
|
||||
->expects($this->once())
|
||||
->method('areWebauthnExtensionsEnabled')
|
||||
|
|
@ -263,12 +257,10 @@ class CheckSetupControllerTest extends TestCase {
|
|||
'hasPassedCodeIntegrityCheck' => true,
|
||||
'codeIntegrityCheckerDocumentation' => 'http://docs.example.org/server/go.php?to=admin-code-integrity',
|
||||
'isSettimelimitAvailable' => true,
|
||||
'isImagickEnabled' => false,
|
||||
'areWebauthnExtensionsEnabled' => false,
|
||||
'isMysqlUsedWithoutUTF8MB4' => false,
|
||||
'isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed' => true,
|
||||
'reverseProxyGeneratedURL' => 'https://server/index.php',
|
||||
'imageMagickLacksSVGSupport' => false,
|
||||
'isFairUseOfFreePushService' => false,
|
||||
'temporaryDirectoryWritable' => false,
|
||||
'generic' => [],
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ return array(
|
|||
'OCA\\Theming\\Settings\\AdminSection' => $baseDir . '/../lib/Settings/AdminSection.php',
|
||||
'OCA\\Theming\\Settings\\Personal' => $baseDir . '/../lib/Settings/Personal.php',
|
||||
'OCA\\Theming\\Settings\\PersonalSection' => $baseDir . '/../lib/Settings/PersonalSection.php',
|
||||
'OCA\\Theming\\SetupChecks\\PhpImagickModule' => $baseDir . '/../lib/SetupChecks/PhpImagickModule.php',
|
||||
'OCA\\Theming\\Themes\\CommonThemeTrait' => $baseDir . '/../lib/Themes/CommonThemeTrait.php',
|
||||
'OCA\\Theming\\Themes\\DarkHighContrastTheme' => $baseDir . '/../lib/Themes/DarkHighContrastTheme.php',
|
||||
'OCA\\Theming\\Themes\\DarkTheme' => $baseDir . '/../lib/Themes/DarkTheme.php',
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ class ComposerStaticInitTheming
|
|||
'OCA\\Theming\\Settings\\AdminSection' => __DIR__ . '/..' . '/../lib/Settings/AdminSection.php',
|
||||
'OCA\\Theming\\Settings\\Personal' => __DIR__ . '/..' . '/../lib/Settings/Personal.php',
|
||||
'OCA\\Theming\\Settings\\PersonalSection' => __DIR__ . '/..' . '/../lib/Settings/PersonalSection.php',
|
||||
'OCA\\Theming\\SetupChecks\\PhpImagickModule' => __DIR__ . '/..' . '/../lib/SetupChecks/PhpImagickModule.php',
|
||||
'OCA\\Theming\\Themes\\CommonThemeTrait' => __DIR__ . '/..' . '/../lib/Themes/CommonThemeTrait.php',
|
||||
'OCA\\Theming\\Themes\\DarkHighContrastTheme' => __DIR__ . '/..' . '/../lib/Themes/DarkHighContrastTheme.php',
|
||||
'OCA\\Theming\\Themes\\DarkTheme' => __DIR__ . '/..' . '/../lib/Themes/DarkTheme.php',
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ namespace OCA\Theming\AppInfo;
|
|||
use OCA\Theming\Capabilities;
|
||||
use OCA\Theming\Listener\BeforePreferenceListener;
|
||||
use OCA\Theming\Listener\BeforeTemplateRenderedListener;
|
||||
use OCA\Theming\SetupChecks\PhpImagickModule;
|
||||
use OCP\AppFramework\App;
|
||||
use OCP\AppFramework\Bootstrap\IBootContext;
|
||||
use OCP\AppFramework\Bootstrap\IBootstrap;
|
||||
|
|
@ -49,6 +50,7 @@ class Application extends App implements IBootstrap {
|
|||
$context->registerEventListener(BeforeLoginTemplateRenderedEvent::class, BeforeTemplateRenderedListener::class);
|
||||
$context->registerEventListener(BeforePreferenceSetEvent::class, BeforePreferenceListener::class);
|
||||
$context->registerEventListener(BeforePreferenceDeletedEvent::class, BeforePreferenceListener::class);
|
||||
$context->registerSetupCheck(PhpImagickModule::class);
|
||||
}
|
||||
|
||||
public function boot(IBootContext $context): void {
|
||||
|
|
|
|||
63
apps/theming/lib/SetupChecks/PhpImagickModule.php
Normal file
63
apps/theming/lib/SetupChecks/PhpImagickModule.php
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* @copyright Copyright (c) 2023 Côme Chilliet <come.chilliet@nextcloud.com>
|
||||
*
|
||||
* @author Côme Chilliet <come.chilliet@nextcloud.com>
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
namespace OCA\Theming\SetupChecks;
|
||||
|
||||
use OCP\IL10N;
|
||||
use OCP\IURLGenerator;
|
||||
use OCP\SetupCheck\ISetupCheck;
|
||||
use OCP\SetupCheck\SetupResult;
|
||||
|
||||
class PhpImagickModule implements ISetupCheck {
|
||||
public function __construct(
|
||||
private IL10N $l10n,
|
||||
private IURLGenerator $urlGenerator,
|
||||
) {
|
||||
}
|
||||
|
||||
public function getName(): string {
|
||||
return $this->l10n->t('PHP Imagick module');
|
||||
}
|
||||
|
||||
public function getCategory(): string {
|
||||
return 'php';
|
||||
}
|
||||
|
||||
public function run(): SetupResult {
|
||||
if (!extension_loaded('imagick')) {
|
||||
return SetupResult::info(
|
||||
$this->l10n->t('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.'),
|
||||
$this->urlGenerator->linkToDocs('admin-php-modules')
|
||||
);
|
||||
} elseif (count(\Imagick::queryFormats('SVG')) === 0) {
|
||||
return SetupResult::info(
|
||||
$this->l10n->t('The PHP module "imagick" in this instance has no SVG support. For better compatibility it is recommended to install it.'),
|
||||
$this->urlGenerator->linkToDocs('admin-php-modules')
|
||||
);
|
||||
} else {
|
||||
return SetupResult::success();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -246,15 +246,6 @@
|
|||
type: OC.SetupChecks.MESSAGE_TYPE_WARNING
|
||||
});
|
||||
}
|
||||
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(
|
||||
|
|
@ -264,12 +255,6 @@
|
|||
type: OC.SetupChecks.MESSAGE_TYPE_INFO
|
||||
})
|
||||
}
|
||||
if (data.imageMagickLacksSVGSupport) {
|
||||
messages.push({
|
||||
msg: t('core', 'Module php-imagick in this instance has no SVG support. For better compatibility it is recommended to install it.'),
|
||||
type: OC.SetupChecks.MESSAGE_TYPE_INFO
|
||||
})
|
||||
}
|
||||
|
||||
if (data.isMysqlUsedWithoutUTF8MB4) {
|
||||
messages.push({
|
||||
|
|
|
|||
|
|
@ -232,7 +232,6 @@ describe('OC.SetupChecks tests', function() {
|
|||
cronInfo: {
|
||||
diffInSeconds: 0
|
||||
},
|
||||
isImagickEnabled: true,
|
||||
areWebauthnExtensionsEnabled: true,
|
||||
isMysqlUsedWithoutUTF8MB4: false,
|
||||
isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true,
|
||||
|
|
@ -279,7 +278,6 @@ describe('OC.SetupChecks tests', function() {
|
|||
cronInfo: {
|
||||
diffInSeconds: 0
|
||||
},
|
||||
isImagickEnabled: true,
|
||||
areWebauthnExtensionsEnabled: true,
|
||||
isMysqlUsedWithoutUTF8MB4: false,
|
||||
isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true,
|
||||
|
|
@ -326,7 +324,6 @@ describe('OC.SetupChecks tests', function() {
|
|||
cronInfo: {
|
||||
diffInSeconds: 0
|
||||
},
|
||||
isImagickEnabled: true,
|
||||
areWebauthnExtensionsEnabled: true,
|
||||
isMysqlUsedWithoutUTF8MB4: false,
|
||||
isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true,
|
||||
|
|
@ -373,7 +370,6 @@ describe('OC.SetupChecks tests', function() {
|
|||
cronInfo: {
|
||||
diffInSeconds: 0
|
||||
},
|
||||
isImagickEnabled: true,
|
||||
areWebauthnExtensionsEnabled: true,
|
||||
isMysqlUsedWithoutUTF8MB4: false,
|
||||
isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true,
|
||||
|
|
@ -419,7 +415,6 @@ describe('OC.SetupChecks tests', function() {
|
|||
cronInfo: {
|
||||
diffInSeconds: 0
|
||||
},
|
||||
isImagickEnabled: true,
|
||||
areWebauthnExtensionsEnabled: true,
|
||||
isMysqlUsedWithoutUTF8MB4: false,
|
||||
isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true,
|
||||
|
|
@ -465,7 +460,6 @@ describe('OC.SetupChecks tests', function() {
|
|||
cronInfo: {
|
||||
diffInSeconds: 0
|
||||
},
|
||||
isImagickEnabled: true,
|
||||
areWebauthnExtensionsEnabled: true,
|
||||
isMysqlUsedWithoutUTF8MB4: false,
|
||||
isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true,
|
||||
|
|
@ -542,7 +536,6 @@ describe('OC.SetupChecks tests', function() {
|
|||
cronInfo: {
|
||||
diffInSeconds: 0
|
||||
},
|
||||
isImagickEnabled: true,
|
||||
areWebauthnExtensionsEnabled: true,
|
||||
isMysqlUsedWithoutUTF8MB4: false,
|
||||
isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true,
|
||||
|
|
@ -594,7 +587,6 @@ describe('OC.SetupChecks tests', function() {
|
|||
cronInfo: {
|
||||
diffInSeconds: 0
|
||||
},
|
||||
isImagickEnabled: true,
|
||||
areWebauthnExtensionsEnabled: true,
|
||||
isMysqlUsedWithoutUTF8MB4: true,
|
||||
isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true,
|
||||
|
|
@ -643,7 +635,6 @@ describe('OC.SetupChecks tests', function() {
|
|||
cronInfo: {
|
||||
diffInSeconds: 0
|
||||
},
|
||||
isImagickEnabled: true,
|
||||
areWebauthnExtensionsEnabled: true,
|
||||
isMysqlUsedWithoutUTF8MB4: false,
|
||||
isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true,
|
||||
|
|
@ -689,7 +680,6 @@ describe('OC.SetupChecks tests', function() {
|
|||
cronInfo: {
|
||||
diffInSeconds: 0
|
||||
},
|
||||
isImagickEnabled: true,
|
||||
areWebauthnExtensionsEnabled: true,
|
||||
isMysqlUsedWithoutUTF8MB4: false,
|
||||
isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true,
|
||||
|
|
@ -732,7 +722,6 @@ describe('OC.SetupChecks tests', function() {
|
|||
cronInfo: {
|
||||
diffInSeconds: 0
|
||||
},
|
||||
isImagickEnabled: true,
|
||||
areWebauthnExtensionsEnabled: true,
|
||||
isMysqlUsedWithoutUTF8MB4: false,
|
||||
isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: false,
|
||||
|
|
@ -760,52 +749,6 @@ 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({
|
||||
suggestedOverwriteCliURL: '',
|
||||
isFairUseOfFreePushService: true,
|
||||
isCorrectMemcachedPHPModuleInstalled: true,
|
||||
hasPassedCodeIntegrityCheck: true,
|
||||
isSettimelimitAvailable: true,
|
||||
cronErrors: [],
|
||||
cronInfo: {
|
||||
diffInSeconds: 0
|
||||
},
|
||||
isImagickEnabled: false,
|
||||
areWebauthnExtensionsEnabled: true,
|
||||
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 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();
|
||||
|
||||
|
|
@ -824,7 +767,6 @@ describe('OC.SetupChecks tests', function() {
|
|||
cronInfo: {
|
||||
diffInSeconds: 0
|
||||
},
|
||||
isImagickEnabled: true,
|
||||
areWebauthnExtensionsEnabled: false,
|
||||
isMysqlUsedWithoutUTF8MB4: false,
|
||||
isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true,
|
||||
|
|
@ -869,7 +811,6 @@ describe('OC.SetupChecks tests', function() {
|
|||
cronInfo: {
|
||||
diffInSeconds: 0
|
||||
},
|
||||
isImagickEnabled: true,
|
||||
areWebauthnExtensionsEnabled: true,
|
||||
isMysqlUsedWithoutUTF8MB4: false,
|
||||
isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true,
|
||||
|
|
@ -921,7 +862,6 @@ describe('OC.SetupChecks tests', function() {
|
|||
cronInfo: {
|
||||
diffInSeconds: 0
|
||||
},
|
||||
isImagickEnabled: true,
|
||||
areWebauthnExtensionsEnabled: true,
|
||||
isMysqlUsedWithoutUTF8MB4: false,
|
||||
isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed: true,
|
||||
|
|
|
|||
Loading…
Reference in a new issue