From 05cb1415e19b97cdd6aaed23a743d198e925f699 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= Date: Mon, 9 Oct 2023 17:08:59 +0200 Subject: [PATCH] Merge setupchecks from new API into old UI MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This will allow migrating checks to the new API without touching the UI for now. Signed-off-by: Côme Chilliet --- .../lib/Controller/CheckSetupController.php | 22 +-------- core/js/setupchecks.js | 48 +++++-------------- 2 files changed, 14 insertions(+), 56 deletions(-) diff --git a/apps/settings/lib/Controller/CheckSetupController.php b/apps/settings/lib/Controller/CheckSetupController.php index 4977d8d17f2..1028d8ca202 100644 --- a/apps/settings/lib/Controller/CheckSetupController.php +++ b/apps/settings/lib/Controller/CheckSetupController.php @@ -329,25 +329,6 @@ class CheckSetupController extends Controller { return ''; } - /** - * Whether the version is outdated - * - * @return bool - */ - protected function isPhpOutdated(): bool { - return PHP_VERSION_ID < 80100; - } - - /** - * Whether the php version is still supported (at time of release) - * according to: https://www.php.net/supported-versions.php - * - * @return array - */ - private function isPhpSupported(): array { - return ['eol' => $this->isPhpOutdated(), 'version' => PHP_VERSION]; - } - /** * Check if the reverse proxy configuration is working as expected * @@ -931,7 +912,6 @@ Raw output 'isRandomnessSecure' => $this->isRandomnessSecure(), 'securityDocs' => $this->urlGenerator->linkToDocs('admin-security'), 'isUsedTlsLibOutdated' => $this->isUsedTlsLibOutdated(), - 'phpSupported' => $this->isPhpSupported(), 'forwardedForHeadersWorking' => $this->forwardedForHeadersWorking(), 'reverseProxyDocs' => $this->urlGenerator->linkToDocs('admin-reverse-proxy'), 'isCorrectMemcachedPHPModuleInstalled' => $this->isCorrectMemcachedPHPModuleInstalled(), @@ -956,8 +936,8 @@ Raw output 'isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed' => $this->isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed(), 'reverseProxyGeneratedURL' => $this->urlGenerator->getAbsoluteURL('index.php'), 'imageMagickLacksSVGSupport' => $this->imageMagickLacksSVGSupport(), - 'isDefaultPhoneRegionSet' => $this->config->getSystemValueString('default_phone_region', '') !== '', 'temporaryDirectoryWritable' => $this->isTemporaryDirectoryWritable(), + 'generic' => $this->setupCheckManager->runAll(), ] ); } diff --git a/core/js/setupchecks.js b/core/js/setupchecks.js index eb5a20c5966..fe67f1ca451 100644 --- a/core/js/setupchecks.js +++ b/core/js/setupchecks.js @@ -245,14 +245,6 @@ type: OC.SetupChecks.MESSAGE_TYPE_WARNING }); } - if (!data.isDefaultPhoneRegionSet) { - messages.push({ - msg: t('core', 'Your installation has no default phone region set. This is required to validate phone numbers in the profile settings without a country code. To allow numbers without a country code, please add "default_phone_region" with the respective {linkstart}ISO 3166-1 code ↗{linkend} of the region to your config file.') - .replace('{linkstart}', '') - .replace('{linkend}', ''), - type: OC.SetupChecks.MESSAGE_TYPE_INFO - }); - } if (data.cronErrors.length > 0) { var listOfCronErrors = ""; data.cronErrors.forEach(function(element){ @@ -311,22 +303,6 @@ type: OC.SetupChecks.MESSAGE_TYPE_WARNING }); } - if (data.phpSupported && data.phpSupported.eol) { - messages.push({ - msg: t('core', 'You are currently running PHP {version}. Upgrade your PHP version to take advantage of {linkstart}performance and security updates provided by the PHP Group ↗{linkend} as soon as your distribution supports it.', { version: data.phpSupported.version }) - .replace('{linkstart}', '') - .replace('{linkend}', ''), - type: OC.SetupChecks.MESSAGE_TYPE_WARNING - }) - } - if (data.phpSupported && data.phpSupported.version.substr(0, 3) === '8.0') { - messages.push({ - msg: t('core', 'PHP 8.0 is now deprecated in Nextcloud 27. Nextcloud 28 may require at least PHP 8.1. Please upgrade to {linkstart}one of the officially supported PHP versions provided by the PHP Group ↗{linkend} as soon as possible.') - .replace('{linkstart}', '') - .replace('{linkend}', ''), - type: OC.SetupChecks.MESSAGE_TYPE_INFO - }) - } if(!data.forwardedForHeadersWorking) { messages.push({ msg: t('core', 'The reverse proxy header configuration is incorrect, or you are accessing Nextcloud from a trusted proxy. If not, this is a security issue and can allow an attacker to spoof their IP address as visible to the Nextcloud. Further information can be found in the {linkstart}documentation ↗{linkend}.') @@ -535,14 +511,16 @@ type: OC.SetupChecks.MESSAGE_TYPE_WARNING }) } - - OC.SetupChecks.addGenericSetupCheck(data, 'OCA\\Settings\\SetupChecks\\PhpDefaultCharset', messages) - OC.SetupChecks.addGenericSetupCheck(data, 'OCA\\Settings\\SetupChecks\\PhpOutputBuffering', messages) - OC.SetupChecks.addGenericSetupCheck(data, 'OCA\\Settings\\SetupChecks\\LegacySSEKeyFormat', messages) - OC.SetupChecks.addGenericSetupCheck(data, 'OCA\\Settings\\SetupChecks\\CheckUserCertificates', messages) - OC.SetupChecks.addGenericSetupCheck(data, 'OCA\\Settings\\SetupChecks\\SupportedDatabase', messages) - OC.SetupChecks.addGenericSetupCheck(data, 'OCA\\Settings\\SetupChecks\\LdapInvalidUuids', messages) - OC.SetupChecks.addGenericSetupCheck(data, 'OCA\\Settings\\SetupChecks\\NeedsSystemAddressBookSync', messages) + if (Object.keys(data.generic).length > 0) { + Object.keys(data.generic).forEach(function(key){ + Object.keys(data.generic[key]).forEach(function(title){ + if (data.generic[key][title].severity != 'success') { + data.generic[key][title].pass = false; + OC.SetupChecks.addGenericSetupCheck(data.generic[key], title, messages); + } + }); + }); + } } else { messages.push({ msg: t('core', 'Error occurred while checking server setup'), @@ -561,7 +539,7 @@ }, addGenericSetupCheck: function(data, check, messages) { - var setupCheck = data[check] || { pass: true, description: '', severity: 'info', linkToDocumentation: null} + var setupCheck = data[check] || { pass: true, description: '', severity: 'info', linkToDoc: null} var type = OC.SetupChecks.MESSAGE_TYPE_INFO if (setupCheck.severity === 'warning') { @@ -571,9 +549,9 @@ } var message = setupCheck.description; - if (setupCheck.linkToDocumentation) { + if (setupCheck.linkToDoc) { message += ' ' + t('core', 'For more details see the {linkstart}documentation ↗{linkend}.') - .replace('{linkstart}', '') + .replace('{linkstart}', '') .replace('{linkend}', ''); } if (setupCheck.elements) {