mirror of
https://github.com/nextcloud/server.git
synced 2026-04-05 09:06:35 -04:00
Migrate Freetype check to SetupCheck API
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
This commit is contained in:
parent
086d3ceecc
commit
ac3da13b38
8 changed files with 67 additions and 94 deletions
|
|
@ -82,6 +82,7 @@ return array(
|
|||
'OCA\\Settings\\SetupChecks\\LegacySSEKeyFormat' => $baseDir . '/../lib/SetupChecks/LegacySSEKeyFormat.php',
|
||||
'OCA\\Settings\\SetupChecks\\MemcacheConfigured' => $baseDir . '/../lib/SetupChecks/MemcacheConfigured.php',
|
||||
'OCA\\Settings\\SetupChecks\\PhpDefaultCharset' => $baseDir . '/../lib/SetupChecks/PhpDefaultCharset.php',
|
||||
'OCA\\Settings\\SetupChecks\\PhpFreetypeSupport' => $baseDir . '/../lib/SetupChecks/PhpFreetypeSupport.php',
|
||||
'OCA\\Settings\\SetupChecks\\PhpGetEnv' => $baseDir . '/../lib/SetupChecks/PhpGetEnv.php',
|
||||
'OCA\\Settings\\SetupChecks\\PhpModules' => $baseDir . '/../lib/SetupChecks/PhpModules.php',
|
||||
'OCA\\Settings\\SetupChecks\\PhpOutdated' => $baseDir . '/../lib/SetupChecks/PhpOutdated.php',
|
||||
|
|
|
|||
|
|
@ -97,6 +97,7 @@ class ComposerStaticInitSettings
|
|||
'OCA\\Settings\\SetupChecks\\LegacySSEKeyFormat' => __DIR__ . '/..' . '/../lib/SetupChecks/LegacySSEKeyFormat.php',
|
||||
'OCA\\Settings\\SetupChecks\\MemcacheConfigured' => __DIR__ . '/..' . '/../lib/SetupChecks/MemcacheConfigured.php',
|
||||
'OCA\\Settings\\SetupChecks\\PhpDefaultCharset' => __DIR__ . '/..' . '/../lib/SetupChecks/PhpDefaultCharset.php',
|
||||
'OCA\\Settings\\SetupChecks\\PhpFreetypeSupport' => __DIR__ . '/..' . '/../lib/SetupChecks/PhpFreetypeSupport.php',
|
||||
'OCA\\Settings\\SetupChecks\\PhpGetEnv' => __DIR__ . '/..' . '/../lib/SetupChecks/PhpGetEnv.php',
|
||||
'OCA\\Settings\\SetupChecks\\PhpModules' => __DIR__ . '/..' . '/../lib/SetupChecks/PhpModules.php',
|
||||
'OCA\\Settings\\SetupChecks\\PhpOutdated' => __DIR__ . '/..' . '/../lib/SetupChecks/PhpOutdated.php',
|
||||
|
|
|
|||
|
|
@ -58,6 +58,7 @@ use OCA\Settings\SetupChecks\LegacySSEKeyFormat;
|
|||
use OCA\Settings\SetupChecks\MemcacheConfigured;
|
||||
use OCA\Settings\SetupChecks\PhpDefaultCharset;
|
||||
use OCA\Settings\SetupChecks\PhpModules;
|
||||
use OCA\Settings\SetupChecks\PhpFreetypeSupport;
|
||||
use OCA\Settings\SetupChecks\PhpGetEnv;
|
||||
use OCA\Settings\SetupChecks\PhpOutdated;
|
||||
use OCA\Settings\SetupChecks\PhpOutputBuffering;
|
||||
|
|
@ -164,6 +165,7 @@ class Application extends App implements IBootstrap {
|
|||
$context->registerSetupCheck(MemcacheConfigured::class);
|
||||
$context->registerSetupCheck(PhpDefaultCharset::class);
|
||||
$context->registerSetupCheck(PhpModules::class);
|
||||
$context->registerSetupCheck(PhpFreetypeSupport::class);
|
||||
$context->registerSetupCheck(PhpGetEnv::class);
|
||||
$context->registerSetupCheck(PhpOutdated::class);
|
||||
$context->registerSetupCheck(PhpOutputBuffering::class);
|
||||
|
|
|
|||
|
|
@ -454,14 +454,6 @@ Raw output
|
|||
return $recommendations;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the required FreeType functions are present
|
||||
* @return bool
|
||||
*/
|
||||
protected function hasFreeTypeSupport() {
|
||||
return function_exists('imagettfbbox') && function_exists('imagettftext');
|
||||
}
|
||||
|
||||
protected function hasMissingIndexes(): array {
|
||||
$indexInfo = new MissingIndexInformation();
|
||||
|
||||
|
|
@ -754,7 +746,6 @@ Raw output
|
|||
'isCorrectMemcachedPHPModuleInstalled' => $this->isCorrectMemcachedPHPModuleInstalled(),
|
||||
'OpcacheSetupRecommendations' => $this->getOpcacheSetupRecommendations(),
|
||||
'isSettimelimitAvailable' => $this->isSettimelimitAvailable(),
|
||||
'hasFreeTypeSupport' => $this->hasFreeTypeSupport(),
|
||||
'missingPrimaryKeys' => $this->hasMissingPrimaryKeys(),
|
||||
'missingIndexes' => $this->hasMissingIndexes(),
|
||||
'missingColumns' => $this->hasMissingColumns(),
|
||||
|
|
|
|||
63
apps/settings/lib/SetupChecks/PhpFreetypeSupport.php
Normal file
63
apps/settings/lib/SetupChecks/PhpFreetypeSupport.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\Settings\SetupChecks;
|
||||
|
||||
use OCP\IL10N;
|
||||
use OCP\SetupCheck\ISetupCheck;
|
||||
use OCP\SetupCheck\SetupResult;
|
||||
|
||||
class PhpFreetypeSupport implements ISetupCheck {
|
||||
public function __construct(
|
||||
private IL10N $l10n,
|
||||
) {
|
||||
}
|
||||
|
||||
public function getName(): string {
|
||||
return $this->l10n->t('Freetype');
|
||||
}
|
||||
|
||||
public function getCategory(): string {
|
||||
return 'php';
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the required FreeType functions are present
|
||||
*/
|
||||
protected function hasFreeTypeSupport(): bool {
|
||||
return function_exists('imagettfbbox') && function_exists('imagettftext');
|
||||
}
|
||||
|
||||
public function run(): SetupResult {
|
||||
if ($this->hasFreeTypeSupport()) {
|
||||
return SetupResult::success($this->l10n->t('Supported'));
|
||||
} else {
|
||||
return SetupResult::info(
|
||||
$this->l10n->t('Your PHP does not have FreeType support, resulting in breakage of profile pictures and the settings interface.'),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -189,7 +189,6 @@ class CheckSetupControllerTest extends TestCase {
|
|||
'getCurlVersion',
|
||||
'isPhpOutdated',
|
||||
'getOpcacheSetupRecommendations',
|
||||
'hasFreeTypeSupport',
|
||||
'hasMissingIndexes',
|
||||
'hasMissingPrimaryKeys',
|
||||
'isSqliteUsed',
|
||||
|
|
@ -328,9 +327,6 @@ class CheckSetupControllerTest extends TestCase {
|
|||
->expects($this->once())
|
||||
->method('getOpcacheSetupRecommendations')
|
||||
->willReturn(['recommendation1', 'recommendation2']);
|
||||
$this->checkSetupController
|
||||
->method('hasFreeTypeSupport')
|
||||
->willReturn(false);
|
||||
$this->checkSetupController
|
||||
->method('hasMissingIndexes')
|
||||
->willReturn([]);
|
||||
|
|
@ -444,7 +440,6 @@ class CheckSetupControllerTest extends TestCase {
|
|||
'isCorrectMemcachedPHPModuleInstalled' => true,
|
||||
'OpcacheSetupRecommendations' => ['recommendation1', 'recommendation2'],
|
||||
'isSettimelimitAvailable' => true,
|
||||
'hasFreeTypeSupport' => false,
|
||||
'isSqliteUsed' => false,
|
||||
'databaseConversionDocumentation' => 'http://docs.example.org/server/go.php?to=admin-db-conversion',
|
||||
'missingIndexes' => [],
|
||||
|
|
|
|||
|
|
@ -264,12 +264,6 @@
|
|||
type: OC.SetupChecks.MESSAGE_TYPE_WARNING
|
||||
});
|
||||
}
|
||||
if (!data.hasFreeTypeSupport) {
|
||||
messages.push({
|
||||
msg: t('core', 'Your PHP does not have FreeType support, resulting in breakage of profile pictures and the settings interface.'),
|
||||
type: OC.SetupChecks.MESSAGE_TYPE_INFO
|
||||
})
|
||||
}
|
||||
if (data.missingIndexes.length > 0) {
|
||||
var listOfMissingIndexes = "";
|
||||
data.missingIndexes.forEach(function(element){
|
||||
|
|
|
|||
|
|
@ -229,7 +229,6 @@ describe('OC.SetupChecks tests', function() {
|
|||
isCorrectMemcachedPHPModuleInstalled: true,
|
||||
OpcacheSetupRecommendations: [],
|
||||
isSettimelimitAvailable: true,
|
||||
hasFreeTypeSupport: true,
|
||||
missingIndexes: [],
|
||||
missingPrimaryKeys: [],
|
||||
missingColumns: [],
|
||||
|
|
@ -285,7 +284,6 @@ describe('OC.SetupChecks tests', function() {
|
|||
isCorrectMemcachedPHPModuleInstalled: true,
|
||||
OpcacheSetupRecommendations: [],
|
||||
isSettimelimitAvailable: true,
|
||||
hasFreeTypeSupport: true,
|
||||
missingIndexes: [],
|
||||
missingPrimaryKeys: [],
|
||||
missingColumns: [],
|
||||
|
|
@ -341,7 +339,6 @@ describe('OC.SetupChecks tests', function() {
|
|||
isCorrectMemcachedPHPModuleInstalled: true,
|
||||
OpcacheSetupRecommendations: [],
|
||||
isSettimelimitAvailable: true,
|
||||
hasFreeTypeSupport: true,
|
||||
missingIndexes: [],
|
||||
missingPrimaryKeys: [],
|
||||
missingColumns: [],
|
||||
|
|
@ -397,7 +394,6 @@ describe('OC.SetupChecks tests', function() {
|
|||
isCorrectMemcachedPHPModuleInstalled: false,
|
||||
OpcacheSetupRecommendations: [],
|
||||
isSettimelimitAvailable: true,
|
||||
hasFreeTypeSupport: true,
|
||||
missingIndexes: [],
|
||||
missingPrimaryKeys: [],
|
||||
missingColumns: [],
|
||||
|
|
@ -451,7 +447,6 @@ describe('OC.SetupChecks tests', function() {
|
|||
isCorrectMemcachedPHPModuleInstalled: true,
|
||||
OpcacheSetupRecommendations: [],
|
||||
isSettimelimitAvailable: true,
|
||||
hasFreeTypeSupport: true,
|
||||
missingIndexes: [],
|
||||
missingPrimaryKeys: [],
|
||||
missingColumns: [],
|
||||
|
|
@ -508,7 +503,6 @@ describe('OC.SetupChecks tests', function() {
|
|||
isCorrectMemcachedPHPModuleInstalled: true,
|
||||
OpcacheSetupRecommendations: [],
|
||||
isSettimelimitAvailable: true,
|
||||
hasFreeTypeSupport: true,
|
||||
missingIndexes: [],
|
||||
missingPrimaryKeys: [],
|
||||
missingColumns: [],
|
||||
|
|
@ -565,7 +559,6 @@ describe('OC.SetupChecks tests', function() {
|
|||
isCorrectMemcachedPHPModuleInstalled: true,
|
||||
OpcacheSetupRecommendations: [],
|
||||
isSettimelimitAvailable: true,
|
||||
hasFreeTypeSupport: true,
|
||||
missingIndexes: [],
|
||||
missingPrimaryKeys: [],
|
||||
missingColumns: [],
|
||||
|
|
@ -620,7 +613,6 @@ describe('OC.SetupChecks tests', function() {
|
|||
isCorrectMemcachedPHPModuleInstalled: true,
|
||||
OpcacheSetupRecommendations: [],
|
||||
isSettimelimitAvailable: false,
|
||||
hasFreeTypeSupport: true,
|
||||
missingIndexes: [],
|
||||
missingPrimaryKeys: [],
|
||||
missingColumns: [],
|
||||
|
|
@ -675,7 +667,6 @@ describe('OC.SetupChecks tests', function() {
|
|||
isCorrectMemcachedPHPModuleInstalled: true,
|
||||
OpcacheSetupRecommendations: [],
|
||||
isSettimelimitAvailable: true,
|
||||
hasFreeTypeSupport: true,
|
||||
missingIndexes: [],
|
||||
missingPrimaryKeys: [],
|
||||
missingColumns: [],
|
||||
|
|
@ -749,7 +740,6 @@ describe('OC.SetupChecks tests', function() {
|
|||
isCorrectMemcachedPHPModuleInstalled: true,
|
||||
OpcacheSetupRecommendations: [],
|
||||
isSettimelimitAvailable: true,
|
||||
hasFreeTypeSupport: true,
|
||||
missingIndexes: [],
|
||||
missingPrimaryKeys: [],
|
||||
missingColumns: [],
|
||||
|
|
@ -810,7 +800,6 @@ describe('OC.SetupChecks tests', function() {
|
|||
isCorrectMemcachedPHPModuleInstalled: true,
|
||||
OpcacheSetupRecommendations: ['recommendation1', 'recommendation2'],
|
||||
isSettimelimitAvailable: true,
|
||||
hasFreeTypeSupport: true,
|
||||
missingIndexes: [],
|
||||
missingPrimaryKeys: [],
|
||||
missingColumns: [],
|
||||
|
|
@ -849,60 +838,6 @@ describe('OC.SetupChecks tests', function() {
|
|||
});
|
||||
});
|
||||
|
||||
it('should return an info if server has no FreeType support', function(done) {
|
||||
var async = OC.SetupChecks.checkSetup();
|
||||
|
||||
suite.server.requests[0].respond(
|
||||
200,
|
||||
{
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
JSON.stringify({
|
||||
suggestedOverwriteCliURL: '',
|
||||
isFairUseOfFreePushService: true,
|
||||
forwardedForHeadersWorking: true,
|
||||
isCorrectMemcachedPHPModuleInstalled: true,
|
||||
OpcacheSetupRecommendations: [],
|
||||
isSettimelimitAvailable: true,
|
||||
hasFreeTypeSupport: false,
|
||||
missingIndexes: [],
|
||||
missingPrimaryKeys: [],
|
||||
missingColumns: [],
|
||||
cronErrors: [],
|
||||
cronInfo: {
|
||||
diffInSeconds: 0
|
||||
},
|
||||
isMemoryLimitSufficient: true,
|
||||
appDirsWithDifferentOwner: [],
|
||||
isImagickEnabled: true,
|
||||
areWebauthnExtensionsEnabled: true,
|
||||
is64bit: true,
|
||||
pendingBigIntConversionColumns: [],
|
||||
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: 'Your PHP does not have FreeType support, resulting in breakage of profile pictures and the settings interface.',
|
||||
type: OC.SetupChecks.MESSAGE_TYPE_INFO
|
||||
}]);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should return an error if the php version is no longer supported', function(done) {
|
||||
var async = OC.SetupChecks.checkSetup();
|
||||
|
||||
|
|
@ -918,7 +853,6 @@ describe('OC.SetupChecks tests', function() {
|
|||
isCorrectMemcachedPHPModuleInstalled: true,
|
||||
OpcacheSetupRecommendations: [],
|
||||
isSettimelimitAvailable: true,
|
||||
hasFreeTypeSupport: true,
|
||||
missingIndexes: [],
|
||||
missingPrimaryKeys: [],
|
||||
missingColumns: [],
|
||||
|
|
@ -976,7 +910,6 @@ describe('OC.SetupChecks tests', function() {
|
|||
isCorrectMemcachedPHPModuleInstalled: true,
|
||||
OpcacheSetupRecommendations: [],
|
||||
isSettimelimitAvailable: true,
|
||||
hasFreeTypeSupport: true,
|
||||
missingIndexes: [],
|
||||
missingPrimaryKeys: [],
|
||||
missingColumns: [],
|
||||
|
|
@ -1031,7 +964,6 @@ describe('OC.SetupChecks tests', function() {
|
|||
isCorrectMemcachedPHPModuleInstalled: true,
|
||||
OpcacheSetupRecommendations: [],
|
||||
isSettimelimitAvailable: true,
|
||||
hasFreeTypeSupport: true,
|
||||
missingIndexes: [],
|
||||
missingPrimaryKeys: [],
|
||||
missingColumns: [],
|
||||
|
|
@ -1083,7 +1015,6 @@ describe('OC.SetupChecks tests', function() {
|
|||
isCorrectMemcachedPHPModuleInstalled: true,
|
||||
OpcacheSetupRecommendations: [],
|
||||
isSettimelimitAvailable: true,
|
||||
hasFreeTypeSupport: true,
|
||||
missingIndexes: [],
|
||||
missingPrimaryKeys: [],
|
||||
missingColumns: [],
|
||||
|
|
@ -1138,7 +1069,6 @@ describe('OC.SetupChecks tests', function() {
|
|||
isCorrectMemcachedPHPModuleInstalled: true,
|
||||
OpcacheSetupRecommendations: [],
|
||||
isSettimelimitAvailable: true,
|
||||
hasFreeTypeSupport: true,
|
||||
missingIndexes: [],
|
||||
missingPrimaryKeys: [],
|
||||
missingColumns: [],
|
||||
|
|
@ -1193,7 +1123,6 @@ describe('OC.SetupChecks tests', function() {
|
|||
isCorrectMemcachedPHPModuleInstalled: true,
|
||||
OpcacheSetupRecommendations: [],
|
||||
isSettimelimitAvailable: true,
|
||||
hasFreeTypeSupport: true,
|
||||
missingIndexes: [],
|
||||
missingPrimaryKeys: [],
|
||||
missingColumns: [],
|
||||
|
|
@ -1247,7 +1176,6 @@ describe('OC.SetupChecks tests', function() {
|
|||
isCorrectMemcachedPHPModuleInstalled: true,
|
||||
OpcacheSetupRecommendations: [],
|
||||
isSettimelimitAvailable: true,
|
||||
hasFreeTypeSupport: true,
|
||||
missingIndexes: [],
|
||||
missingPrimaryKeys: [],
|
||||
missingColumns: [],
|
||||
|
|
@ -1301,7 +1229,6 @@ describe('OC.SetupChecks tests', function() {
|
|||
isCorrectMemcachedPHPModuleInstalled: true,
|
||||
OpcacheSetupRecommendations: [],
|
||||
isSettimelimitAvailable: true,
|
||||
hasFreeTypeSupport: true,
|
||||
missingIndexes: [],
|
||||
missingPrimaryKeys: [],
|
||||
missingColumns: [],
|
||||
|
|
@ -1362,7 +1289,6 @@ describe('OC.SetupChecks tests', function() {
|
|||
isCorrectMemcachedPHPModuleInstalled: true,
|
||||
OpcacheSetupRecommendations: [],
|
||||
isSettimelimitAvailable: true,
|
||||
hasFreeTypeSupport: true,
|
||||
missingIndexes: [],
|
||||
missingPrimaryKeys: [],
|
||||
missingColumns: [],
|
||||
|
|
|
|||
Loading…
Reference in a new issue