aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorCôme Chilliet <come.chilliet@nextcloud.com>2023-10-16 17:23:47 +0200
committerCôme Chilliet <come.chilliet@nextcloud.com>2023-10-19 11:44:03 +0200
commit2e4d1549a44ce3b29d3287ba3721a464733bf708 (patch)
treeb7ab204e34f2920ebd0f339bc53f292a5f797158 /apps
parent11ebf469da14224b3e1146b65eb16095ab8b22a8 (diff)
downloadnextcloud-server-2e4d1549a44ce3b29d3287ba3721a464733bf708.tar.gz
nextcloud-server-2e4d1549a44ce3b29d3287ba3721a464733bf708.zip
Change SetupResult API to named constructors
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Diffstat (limited to 'apps')
-rw-r--r--apps/dav/lib/SetupChecks/NeedsSystemAddressBookSync.php4
-rw-r--r--apps/settings/lib/SetupChecks/CheckUserCertificates.php8
-rw-r--r--apps/settings/lib/SetupChecks/DefaultPhoneRegionSet.php5
-rw-r--r--apps/settings/lib/SetupChecks/InternetConnectivity.php6
-rw-r--r--apps/settings/lib/SetupChecks/LegacySSEKeyFormat.php4
-rw-r--r--apps/settings/lib/SetupChecks/PhpDefaultCharset.php4
-rw-r--r--apps/settings/lib/SetupChecks/PhpOutdated.php4
-rw-r--r--apps/settings/lib/SetupChecks/PhpOutputBuffering.php4
-rw-r--r--apps/settings/lib/SetupChecks/ReadOnlyConfig.php4
-rw-r--r--apps/settings/lib/SetupChecks/SupportedDatabase.php8
-rw-r--r--apps/user_ldap/lib/SetupChecks/LdapInvalidUuids.php4
11 files changed, 27 insertions, 28 deletions
diff --git a/apps/dav/lib/SetupChecks/NeedsSystemAddressBookSync.php b/apps/dav/lib/SetupChecks/NeedsSystemAddressBookSync.php
index 78f8a1bff69..476b37c1602 100644
--- a/apps/dav/lib/SetupChecks/NeedsSystemAddressBookSync.php
+++ b/apps/dav/lib/SetupChecks/NeedsSystemAddressBookSync.php
@@ -49,9 +49,9 @@ class NeedsSystemAddressBookSync implements ISetupCheck {
public function run(): SetupResult {
if ($this->config->getAppValue('dav', 'needs_system_address_book_sync', 'no') === 'no') {
- return new SetupResult(SetupResult::SUCCESS, $this->l10n->t('No outstanding DAV system address book sync.'));
+ return SetupResult::success($this->l10n->t('No outstanding DAV system address book sync.'));
} else {
- return new SetupResult(SetupResult::WARNING, $this->l10n->t('The DAV system address book sync has not run yet as your instance has more than 1000 users or because an error occurred. Please run it manually by calling occ dav:sync-system-addressbook.'));
+ return SetupResult::warning($this->l10n->t('The DAV system address book sync has not run yet as your instance has more than 1000 users or because an error occurred. Please run it manually by calling occ dav:sync-system-addressbook.'));
}
}
}
diff --git a/apps/settings/lib/SetupChecks/CheckUserCertificates.php b/apps/settings/lib/SetupChecks/CheckUserCertificates.php
index 909ba9e149b..e09ef267e07 100644
--- a/apps/settings/lib/SetupChecks/CheckUserCertificates.php
+++ b/apps/settings/lib/SetupChecks/CheckUserCertificates.php
@@ -38,7 +38,7 @@ class CheckUserCertificates implements ISetupCheck {
private IL10N $l10n,
IConfig $config,
) {
- $this->configValue = $config->getAppValue('files_external', 'user_certificate_scan', '');
+ $this->configValue = $config->getAppValue('files_external', 'user_certificate_scan', '');
}
public function getCategory(): string {
@@ -52,11 +52,11 @@ class CheckUserCertificates implements ISetupCheck {
public function run(): SetupResult {
// all fine if neither "not-run-yet" nor a result
if ($this->configValue === '') {
- return new SetupResult(SetupResult::SUCCESS);
+ return SetupResult::success();
}
if ($this->configValue === 'not-run-yet') {
- return new SetupResult(SetupResult::INFO, $this->l10n->t('A background job is pending that checks for user imported SSL certificates. Please check back later.'));
+ return SetupResult::info($this->l10n->t('A background job is pending that checks for user imported SSL certificates. Please check back later.'));
}
- return new SetupResult(SetupResult::ERROR, $this->l10n->t('There are some user imported SSL certificates present, that are not used anymore with Nextcloud 21. They can be imported on the command line via "occ security:certificates:import" command. Their paths inside the data directory are shown below.'));
+ return SetupResult::error($this->l10n->t('There are some user imported SSL certificates present, that are not used anymore with Nextcloud 21. They can be imported on the command line via "occ security:certificates:import" command. Their paths inside the data directory are shown below.'));
}
}
diff --git a/apps/settings/lib/SetupChecks/DefaultPhoneRegionSet.php b/apps/settings/lib/SetupChecks/DefaultPhoneRegionSet.php
index 6cc37b08abe..8b11ea90fdd 100644
--- a/apps/settings/lib/SetupChecks/DefaultPhoneRegionSet.php
+++ b/apps/settings/lib/SetupChecks/DefaultPhoneRegionSet.php
@@ -47,10 +47,9 @@ class DefaultPhoneRegionSet implements ISetupCheck {
public function run(): SetupResult {
if ($this->config->getSystemValueString('default_phone_region', '') !== '') {
- return new SetupResult(SetupResult::SUCCESS, $this->config->getSystemValueString('default_phone_region', ''));
+ return SetupResult::success($this->config->getSystemValueString('default_phone_region', ''));
} else {
- return new SetupResult(
- SetupResult::INFO,
+ return SetupResult::info(
$this->l10n->t('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 ISO 3166-1 code of the region to your config file.'),
'https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements'
);
diff --git a/apps/settings/lib/SetupChecks/InternetConnectivity.php b/apps/settings/lib/SetupChecks/InternetConnectivity.php
index 697dddc935a..e27c5e2e981 100644
--- a/apps/settings/lib/SetupChecks/InternetConnectivity.php
+++ b/apps/settings/lib/SetupChecks/InternetConnectivity.php
@@ -57,7 +57,7 @@ class InternetConnectivity implements ISetupCheck {
public function run(): SetupResult {
if ($this->config->getSystemValue('has_internet_connection', true) === false) {
- return new SetupResult(SetupResult::SUCCESS, $this->l10n->t('Internet connectivity is disabled in configuration file.'));
+ return SetupResult::success($this->l10n->t('Internet connectivity is disabled in configuration file.'));
}
$siteArray = $this->config->getSystemValue('connectivity_check_domains', [
@@ -66,10 +66,10 @@ class InternetConnectivity implements ISetupCheck {
foreach ($siteArray as $site) {
if ($this->isSiteReachable($site)) {
- return new SetupResult(SetupResult::SUCCESS);
+ return SetupResult::success();
}
}
- return new SetupResult(SetupResult::WARNING, $this->l10n->t('This server has no working internet connection: Multiple endpoints could not be reached. This means that some of the features like mounting external storage, notifications about updates or installation of third-party apps will not work. Accessing files remotely and sending of notification emails might not work, either. Establish a connection from this server to the internet to enjoy all features.'));
+ return SetupResult::warning($this->l10n->t('This server has no working internet connection: Multiple endpoints could not be reached. This means that some of the features like mounting external storage, notifications about updates or installation of third-party apps will not work. Accessing files remotely and sending of notification emails might not work, either. Establish a connection from this server to the internet to enjoy all features.'));
}
/**
diff --git a/apps/settings/lib/SetupChecks/LegacySSEKeyFormat.php b/apps/settings/lib/SetupChecks/LegacySSEKeyFormat.php
index 68964b3fdab..72300ede2b0 100644
--- a/apps/settings/lib/SetupChecks/LegacySSEKeyFormat.php
+++ b/apps/settings/lib/SetupChecks/LegacySSEKeyFormat.php
@@ -49,8 +49,8 @@ class LegacySSEKeyFormat implements ISetupCheck {
public function run(): SetupResult {
if ($this->config->getSystemValueBool('encryption.legacy_format_support', false) === false) {
- return new SetupResult(SetupResult::SUCCESS);
+ return SetupResult::success();
}
- return new SetupResult(SetupResult::WARNING, $this->l10n->t('The old server-side-encryption format is enabled. We recommend disabling this.'), $this->urlGenerator->linkToDocs('admin-sse-legacy-format'));
+ return SetupResult::warning($this->l10n->t('The old server-side-encryption format is enabled. We recommend disabling this.'), $this->urlGenerator->linkToDocs('admin-sse-legacy-format'));
}
}
diff --git a/apps/settings/lib/SetupChecks/PhpDefaultCharset.php b/apps/settings/lib/SetupChecks/PhpDefaultCharset.php
index 5c14e9a6734..3f7a8c58e52 100644
--- a/apps/settings/lib/SetupChecks/PhpDefaultCharset.php
+++ b/apps/settings/lib/SetupChecks/PhpDefaultCharset.php
@@ -45,9 +45,9 @@ class PhpDefaultCharset implements ISetupCheck {
public function run(): SetupResult {
if (strtoupper(trim(ini_get('default_charset'))) === 'UTF-8') {
- return new SetupResult(SetupResult::SUCCESS);
+ return SetupResult::success();
} else {
- return new SetupResult(SetupResult::WARNING, $this->l10n->t('PHP configuration option default_charset should be UTF-8'));
+ return SetupResult::warning($this->l10n->t('PHP configuration option default_charset should be UTF-8'));
}
}
}
diff --git a/apps/settings/lib/SetupChecks/PhpOutdated.php b/apps/settings/lib/SetupChecks/PhpOutdated.php
index 51b479ec4b9..2d161649315 100644
--- a/apps/settings/lib/SetupChecks/PhpOutdated.php
+++ b/apps/settings/lib/SetupChecks/PhpOutdated.php
@@ -47,8 +47,8 @@ class PhpOutdated implements ISetupCheck {
public function run(): SetupResult {
if (PHP_VERSION_ID < 80100) {
- return new SetupResult(SetupResult::WARNING, $this->l10n->t('You are currently running PHP %s. PHP 8.0 is now deprecated in Nextcloud 27. Nextcloud 28 may require at least PHP 8.1. Please upgrade to one of the officially supported PHP versions provided by the PHP Group as soon as possible.', [PHP_VERSION]), 'https://secure.php.net/supported-versions.php');
+ return SetupResult::warning($this->l10n->t('You are currently running PHP %s. PHP 8.0 is now deprecated in Nextcloud 27. Nextcloud 28 may require at least PHP 8.1. Please upgrade to one of the officially supported PHP versions provided by the PHP Group as soon as possible.', [PHP_VERSION]), 'https://secure.php.net/supported-versions.php');
}
- return new SetupResult(SetupResult::SUCCESS, $this->l10n->t('You are currently running PHP %s.', [PHP_VERSION]));
+ return SetupResult::success($this->l10n->t('You are currently running PHP %s.', [PHP_VERSION]));
}
}
diff --git a/apps/settings/lib/SetupChecks/PhpOutputBuffering.php b/apps/settings/lib/SetupChecks/PhpOutputBuffering.php
index f3a21418c1c..58321e9f5dc 100644
--- a/apps/settings/lib/SetupChecks/PhpOutputBuffering.php
+++ b/apps/settings/lib/SetupChecks/PhpOutputBuffering.php
@@ -46,9 +46,9 @@ class PhpOutputBuffering implements ISetupCheck {
public function run(): SetupResult {
$value = trim(ini_get('output_buffering'));
if ($value === '' || $value === '0') {
- return new SetupResult(SetupResult::SUCCESS);
+ return SetupResult::success();
} else {
- return new SetupResult(SetupResult::ERROR, $this->l10n->t('PHP configuration option output_buffering must be disabled'));
+ return SetupResult::error($this->l10n->t('PHP configuration option output_buffering must be disabled'));
}
}
}
diff --git a/apps/settings/lib/SetupChecks/ReadOnlyConfig.php b/apps/settings/lib/SetupChecks/ReadOnlyConfig.php
index 4c81a410449..56f86ba9ab4 100644
--- a/apps/settings/lib/SetupChecks/ReadOnlyConfig.php
+++ b/apps/settings/lib/SetupChecks/ReadOnlyConfig.php
@@ -47,9 +47,9 @@ class ReadOnlyConfig implements ISetupCheck {
public function run(): SetupResult {
if ($this->config->getSystemValueBool('config_is_read_only', false)) {
- return new SetupResult(SetupResult::INFO, $this->l10n->t('The read-only config has been enabled. This prevents setting some configurations via the web-interface. Furthermore, the file needs to be made writable manually for every update.'));
+ return SetupResult::info($this->l10n->t('The read-only config has been enabled. This prevents setting some configurations via the web-interface. Furthermore, the file needs to be made writable manually for every update.'));
} else {
- return new SetupResult(SetupResult::SUCCESS, $this->l10n->t('Nextcloud configuration file is writable'));
+ return SetupResult::success($this->l10n->t('Nextcloud configuration file is writable'));
}
}
}
diff --git a/apps/settings/lib/SetupChecks/SupportedDatabase.php b/apps/settings/lib/SetupChecks/SupportedDatabase.php
index 0cbaa5b114e..3d10798a7da 100644
--- a/apps/settings/lib/SetupChecks/SupportedDatabase.php
+++ b/apps/settings/lib/SetupChecks/SupportedDatabase.php
@@ -68,11 +68,11 @@ class SupportedDatabase implements ISetupCheck {
if (str_contains($version, 'mariadb')) {
if (version_compare($version, '10.2', '<')) {
- return new SetupResult(SetupResult::WARNING, $this->l10n->t('MariaDB version "%s" is used. Nextcloud 21 and higher do not support this version and require MariaDB 10.2 or higher.', $row['Value']));
+ return SetupResult::warning($this->l10n->t('MariaDB version "%s" is used. Nextcloud 21 and higher do not support this version and require MariaDB 10.2 or higher.', $row['Value']));
}
} else {
if (version_compare($version, '8', '<')) {
- return new SetupResult(SetupResult::WARNING, $this->l10n->t('MySQL version "%s" is used. Nextcloud 21 and higher do not support this version and require MySQL 8.0 or MariaDB 10.2 or higher.', $row['Value']));
+ return SetupResult::warning($this->l10n->t('MySQL version "%s" is used. Nextcloud 21 and higher do not support this version and require MySQL 8.0 or MariaDB 10.2 or higher.', $row['Value']));
}
}
break;
@@ -84,13 +84,13 @@ class SupportedDatabase implements ISetupCheck {
$result->execute();
$row = $result->fetch();
if (version_compare($row['server_version'], '9.6', '<')) {
- return new SetupResult(SetupResult::WARNING, $this->l10n->t('PostgreSQL version "%s" is used. Nextcloud 21 and higher do not support this version and require PostgreSQL 9.6 or higher.', $row['server_version']));
+ return SetupResult::warning($this->l10n->t('PostgreSQL version "%s" is used. Nextcloud 21 and higher do not support this version and require PostgreSQL 9.6 or higher.', $row['server_version']));
}
break;
case OraclePlatform::class:
break;
}
// TODO still show db and version on success?
- return new SetupResult(SetupResult::SUCCESS);
+ return SetupResult::success();
}
}
diff --git a/apps/user_ldap/lib/SetupChecks/LdapInvalidUuids.php b/apps/user_ldap/lib/SetupChecks/LdapInvalidUuids.php
index a11246fd142..d6de11d35b9 100644
--- a/apps/user_ldap/lib/SetupChecks/LdapInvalidUuids.php
+++ b/apps/user_ldap/lib/SetupChecks/LdapInvalidUuids.php
@@ -52,9 +52,9 @@ class LdapInvalidUuids implements ISetupCheck {
public function run(): SetupResult {
if (count($this->userMapping->getList(0, 1, true)) === 0
&& count($this->groupMapping->getList(0, 1, true)) === 0) {
- return new SetupResult(SetupResult::SUCCESS);
+ return SetupResult::success();
} else {
- return new SetupResult(SetupResult::WARNING, $this->l10n->t('Invalid UUIDs of LDAP users or groups have been found. Please review your "Override UUID detection" settings in the Expert part of the LDAP configuration and use "occ ldap:update-uuid" to update them.'));
+ return SetupResult::warning($this->l10n->t('Invalid UUIDs of LDAP users or groups have been found. Please review your "Override UUID detection" settings in the Expert part of the LDAP configuration and use "occ ldap:update-uuid" to update them.'));
}
}
}