From 426c0341ffff262f58d1b7f031de4f0c53c8bec5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= Date: Wed, 5 Apr 2023 12:50:08 +0200 Subject: [PATCH] Use typed version of IConfig::getSystemValue as much as possible MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Côme Chilliet --- lib/base.php | 8 +++---- lib/private/App/AppStore/Fetcher/Fetcher.php | 14 ++++++------- lib/private/App/Platform.php | 2 +- lib/private/AppFramework/Http/Request.php | 14 ++++++------- .../Login/FinishRememberedLoginCommand.php | 2 +- .../Token/PublicKeyTokenProvider.php | 10 ++++----- .../Collaborators/LookupPlugin.php | 4 ++-- lib/private/Console/Application.php | 2 +- lib/private/DB/Migrator.php | 2 +- lib/private/DB/OracleMigrator.php | 2 +- lib/private/DB/PgSqlTools.php | 2 +- lib/private/Encryption/Keys/Storage.php | 6 +++--- lib/private/Encryption/Manager.php | 2 +- lib/private/Encryption/Util.php | 4 ++-- lib/private/Files/Cache/Scanner.php | 4 ++-- .../Files/Mount/CacheMountProvider.php | 2 +- lib/private/Files/Storage/Common.php | 2 +- lib/private/Files/Storage/DAV.php | 2 +- lib/private/Files/Storage/Local.php | 4 ++-- .../Files/Template/TemplateManager.php | 4 ++-- lib/private/GlobalScale/Config.php | 5 ++--- lib/private/Http/Client/Client.php | 10 ++++----- lib/private/IntegrityCheck/Checker.php | 4 ++-- .../ExcludeFoldersByPathFilterIterator.php | 2 +- lib/private/L10N/Factory.php | 12 +++++------ lib/private/L10N/LanguageIterator.php | 2 +- lib/private/Log/Rotate.php | 2 +- lib/private/Mail/Mailer.php | 21 +++++++++---------- lib/private/NavigationManager.php | 2 +- lib/private/Preview/Imaginary.php | 4 ++-- lib/private/PreviewManager.php | 2 +- .../Repair/ClearGeneratedAvatarCache.php | 2 +- lib/private/Repair/Collation.php | 6 +++--- lib/private/Repair/MoveUpdaterStepFile.php | 4 ++-- .../Repair/NC16/CleanupCardDAVPhotoCache.php | 2 +- .../NC16/ClearCollectionsAccessCache.php | 2 +- .../Repair/NC18/ResetGeneratedAvatarFlag.php | 2 +- .../Repair/NC20/EncryptionLegacyCipher.php | 2 +- .../Repair/NC20/EncryptionMigration.php | 2 +- .../NC21/AddCheckForUserCertificatesJob.php | 2 +- .../Repair/NC22/LookupServerSendCheck.php | 2 +- .../Repair/NC25/AddMissingSecretJob.php | 8 +++---- lib/private/Repair/Owncloud/MoveAvatars.php | 2 +- .../Repair/Owncloud/SaveAccountsTableData.php | 4 ++-- .../Repair/Owncloud/UpdateLanguageCodes.php | 2 +- lib/private/Repair/RemoveLinkShares.php | 2 +- lib/private/Repair/RepairDavShares.php | 2 +- lib/private/Repair/RepairInvalidShares.php | 2 +- lib/private/Repair/RepairMimeTypes.php | 2 +- .../Security/Bruteforce/Capabilities.php | 2 +- lib/private/Security/Bruteforce/Throttler.php | 4 ++-- lib/private/Security/CertificateManager.php | 4 ++-- lib/private/Security/Crypto.php | 4 ++-- lib/private/Security/Hasher.php | 2 +- .../VerificationToken/VerificationToken.php | 4 ++-- lib/private/Server.php | 10 ++++----- lib/private/Setup.php | 4 ++-- lib/private/Share20/Manager.php | 2 +- lib/private/Support/Subscription/Registry.php | 2 +- lib/private/TemplateLayout.php | 6 +++--- lib/private/URLGenerator.php | 8 +++---- lib/private/Updater.php | 8 +++---- lib/private/Updater/VersionCheck.php | 2 +- lib/private/User/Database.php | 2 +- lib/private/User/Session.php | 6 +++--- lib/private/User/User.php | 4 ++-- lib/private/legacy/OC_FileChunking.php | 2 +- lib/private/legacy/OC_Helper.php | 2 +- lib/private/legacy/OC_Util.php | 12 +++++------ 69 files changed, 148 insertions(+), 150 deletions(-) diff --git a/lib/base.php b/lib/base.php index 86005a96954..e0ec23151e3 100644 --- a/lib/base.php +++ b/lib/base.php @@ -569,7 +569,7 @@ class OC { self::sendSameSiteCookies(); // Debug mode gets access to the resources without strict cookie // due to the fact that the SabreDAV browser also lives there. - if (!$config->getSystemValue('debug', false)) { + if (!$config->getSystemValueBool('debug', false)) { http_response_code(\OCP\AppFramework\Http::STATUS_SERVICE_UNAVAILABLE); exit(); } @@ -672,7 +672,7 @@ class OC { \OCP\Server::get(\Psr\Log\LoggerInterface::class), ); $exceptionHandler = [$errorHandler, 'onException']; - if ($config->getSystemValue('debug', false)) { + if ($config->getSystemValueBool('debug', false)) { set_error_handler([$errorHandler, 'onAll'], E_ALL); if (\OC::$CLI) { $exceptionHandler = ['OC_Template', 'printExceptionErrorPage']; @@ -733,7 +733,7 @@ class OC { echo('Writing to database failed'); } exit(1); - } elseif (self::$CLI && $config->getSystemValue('installed', false)) { + } elseif (self::$CLI && $config->getSystemValueBool('installed', false)) { $config->deleteAppValue('core', 'cronErrors'); } } @@ -803,7 +803,7 @@ class OC { */ if (!OC::$CLI && !Server::get(\OC\Security\TrustedDomainHelper::class)->isTrustedDomain($host) - && $config->getSystemValue('installed', false) + && $config->getSystemValueBool('installed', false) ) { // Allow access to CSS resources $isScssRequest = false; diff --git a/lib/private/App/AppStore/Fetcher/Fetcher.php b/lib/private/App/AppStore/Fetcher/Fetcher.php index 0eb089bbdc2..095b026cb44 100644 --- a/lib/private/App/AppStore/Fetcher/Fetcher.php +++ b/lib/private/App/AppStore/Fetcher/Fetcher.php @@ -62,10 +62,10 @@ abstract class Fetcher { protected $fileName; /** @var string */ protected $endpointName; - /** @var string */ - protected $version; - /** @var string */ - protected $channel; + /** @var ?string */ + protected $version = null; + /** @var ?string */ + protected $channel = null; public function __construct(Factory $appDataFactory, IClientService $clientService, @@ -149,7 +149,7 @@ abstract class Fetcher { */ public function get($allowUnstable = false) { $appstoreenabled = $this->config->getSystemValueBool('appstoreenabled', true); - $internetavailable = $this->config->getSystemValue('has_internet_connection', true); + $internetavailable = $this->config->getSystemValueBool('has_internet_connection', true); if (!$appstoreenabled || !$internetavailable) { return []; @@ -218,7 +218,7 @@ abstract class Fetcher { */ protected function getVersion() { if ($this->version === null) { - $this->version = $this->config->getSystemValue('version', '0.0.0'); + $this->version = $this->config->getSystemValueString('version', '0.0.0'); } return $this->version; } @@ -251,6 +251,6 @@ abstract class Fetcher { } protected function getEndpoint(): string { - return $this->config->getSystemValue('appstoreurl', 'https://apps.nextcloud.com/api/v1') . '/' . $this->endpointName; + return $this->config->getSystemValueString('appstoreurl', 'https://apps.nextcloud.com/api/v1') . '/' . $this->endpointName; } } diff --git a/lib/private/App/Platform.php b/lib/private/App/Platform.php index 01bf6748654..1cab740bebb 100644 --- a/lib/private/App/Platform.php +++ b/lib/private/App/Platform.php @@ -56,7 +56,7 @@ class Platform { } public function getDatabase(): string { - $dbType = $this->config->getSystemValue('dbtype', 'sqlite'); + $dbType = $this->config->getSystemValueString('dbtype', 'sqlite'); if ($dbType === 'sqlite3') { $dbType = 'sqlite'; } diff --git a/lib/private/AppFramework/Http/Request.php b/lib/private/AppFramework/Http/Request.php index 1f32d6c5461..52abb909b60 100644 --- a/lib/private/AppFramework/Http/Request.php +++ b/lib/private/AppFramework/Http/Request.php @@ -624,7 +624,7 @@ class Request implements \ArrayAccess, \Countable, IRequest { * @return bool */ private function isOverwriteCondition(string $type = ''): bool { - $regex = '/' . $this->config->getSystemValue('overwritecondaddr', '') . '/'; + $regex = '/' . $this->config->getSystemValueString('overwritecondaddr', '') . '/'; $remoteAddr = isset($this->server['REMOTE_ADDR']) ? $this->server['REMOTE_ADDR'] : ''; return $regex === '//' || preg_match($regex, $remoteAddr) === 1 || $type !== 'protocol'; @@ -636,9 +636,9 @@ class Request implements \ArrayAccess, \Countable, IRequest { * @return string Server protocol (http or https) */ public function getServerProtocol(): string { - if ($this->config->getSystemValue('overwriteprotocol') !== '' + if ($this->config->getSystemValueString('overwriteprotocol') !== '' && $this->isOverwriteCondition('protocol')) { - return $this->config->getSystemValue('overwriteprotocol'); + return $this->config->getSystemValueString('overwriteprotocol'); } if ($this->fromTrustedProxy() && isset($this->server['HTTP_X_FORWARDED_PROTO'])) { @@ -696,7 +696,7 @@ class Request implements \ArrayAccess, \Countable, IRequest { */ public function getRequestUri(): string { $uri = isset($this->server['REQUEST_URI']) ? $this->server['REQUEST_URI'] : ''; - if ($this->config->getSystemValue('overwritewebroot') !== '' && $this->isOverwriteCondition()) { + if ($this->config->getSystemValueString('overwritewebroot') !== '' && $this->isOverwriteCondition()) { $uri = $this->getScriptName() . substr($uri, \strlen($this->server['SCRIPT_NAME'])); } return $uri; @@ -764,7 +764,7 @@ class Request implements \ArrayAccess, \Countable, IRequest { */ public function getScriptName(): string { $name = $this->server['SCRIPT_NAME']; - $overwriteWebRoot = $this->config->getSystemValue('overwritewebroot'); + $overwriteWebRoot = $this->config->getSystemValueString('overwritewebroot'); if ($overwriteWebRoot !== '' && $this->isOverwriteCondition()) { // FIXME: This code is untestable due to __DIR__, also that hardcoded path is really dangerous $serverRoot = str_replace('\\', '/', substr(__DIR__, 0, -\strlen('lib/private/appframework/http/'))); @@ -859,8 +859,8 @@ class Request implements \ArrayAccess, \Countable, IRequest { * isn't met */ private function getOverwriteHost() { - if ($this->config->getSystemValue('overwritehost') !== '' && $this->isOverwriteCondition()) { - return $this->config->getSystemValue('overwritehost'); + if ($this->config->getSystemValueString('overwritehost') !== '' && $this->isOverwriteCondition()) { + return $this->config->getSystemValueString('overwritehost'); } return null; } diff --git a/lib/private/Authentication/Login/FinishRememberedLoginCommand.php b/lib/private/Authentication/Login/FinishRememberedLoginCommand.php index 04ed7ed846e..56ea042a662 100644 --- a/lib/private/Authentication/Login/FinishRememberedLoginCommand.php +++ b/lib/private/Authentication/Login/FinishRememberedLoginCommand.php @@ -41,7 +41,7 @@ class FinishRememberedLoginCommand extends ALoginCommand { } public function process(LoginData $loginData): LoginResult { - if ($loginData->isRememberLogin() && $this->config->getSystemValue('auto_logout', false) === false) { + if ($loginData->isRememberLogin() && !$this->config->getSystemValueBool('auto_logout', false)) { $this->userSession->createRememberMeToken($loginData->getUser()); } diff --git a/lib/private/Authentication/Token/PublicKeyTokenProvider.php b/lib/private/Authentication/Token/PublicKeyTokenProvider.php index 824e2e056c8..6e3bcec5c99 100644 --- a/lib/private/Authentication/Token/PublicKeyTokenProvider.php +++ b/lib/private/Authentication/Token/PublicKeyTokenProvider.php @@ -265,10 +265,10 @@ class PublicKeyTokenProvider implements IProvider { public function invalidateOldTokens() { $this->cache->clear(); - $olderThan = $this->time->getTime() - (int) $this->config->getSystemValue('session_lifetime', 60 * 60 * 24); + $olderThan = $this->time->getTime() - $this->config->getSystemValueInt('session_lifetime', 60 * 60 * 24); $this->logger->debug('Invalidating session tokens older than ' . date('c', $olderThan), ['app' => 'cron']); $this->mapper->invalidateOld($olderThan, IToken::DO_NOT_REMEMBER); - $rememberThreshold = $this->time->getTime() - (int) $this->config->getSystemValue('remember_login_cookie_lifetime', 60 * 60 * 24 * 15); + $rememberThreshold = $this->time->getTime() - $this->config->getSystemValueInt('remember_login_cookie_lifetime', 60 * 60 * 24 * 15); $this->logger->debug('Invalidating remembered session tokens older than ' . date('c', $rememberThreshold), ['app' => 'cron']); $this->mapper->invalidateOld($rememberThreshold, IToken::REMEMBER); } @@ -364,7 +364,7 @@ class PublicKeyTokenProvider implements IProvider { } private function encrypt(string $plaintext, string $token): string { - $secret = $this->config->getSystemValue('secret'); + $secret = $this->config->getSystemValueString('secret'); return $this->crypto->encrypt($plaintext, $token . $secret); } @@ -372,7 +372,7 @@ class PublicKeyTokenProvider implements IProvider { * @throws InvalidTokenException */ private function decrypt(string $cipherText, string $token): string { - $secret = $this->config->getSystemValue('secret'); + $secret = $this->config->getSystemValueString('secret'); try { return $this->crypto->decrypt($cipherText, $token . $secret); } catch (\Exception $ex) { @@ -402,7 +402,7 @@ class PublicKeyTokenProvider implements IProvider { } private function hashToken(string $token): string { - $secret = $this->config->getSystemValue('secret'); + $secret = $this->config->getSystemValueString('secret'); return hash('sha512', $token . $secret); } diff --git a/lib/private/Collaboration/Collaborators/LookupPlugin.php b/lib/private/Collaboration/Collaborators/LookupPlugin.php index a9038a0aa35..86ac70ab970 100644 --- a/lib/private/Collaboration/Collaborators/LookupPlugin.php +++ b/lib/private/Collaboration/Collaborators/LookupPlugin.php @@ -63,7 +63,7 @@ class LookupPlugin implements ISearchPlugin { } public function search($search, $limit, $offset, ISearchResult $searchResult) { - $isGlobalScaleEnabled = $this->config->getSystemValue('gs.enabled', false); + $isGlobalScaleEnabled = $this->config->getSystemValueBool('gs.enabled', false); $isLookupServerEnabled = $this->config->getAppValue('files_sharing', 'lookupServerEnabled', 'yes') === 'yes'; $hasInternetConnection = $this->config->getSystemValueBool('has_internet_connection', true); @@ -72,7 +72,7 @@ class LookupPlugin implements ISearchPlugin { return false; } - $lookupServerUrl = $this->config->getSystemValue('lookup_server', 'https://lookup.nextcloud.com'); + $lookupServerUrl = $this->config->getSystemValueString('lookup_server', 'https://lookup.nextcloud.com'); if (empty($lookupServerUrl)) { return false; } diff --git a/lib/private/Console/Application.php b/lib/private/Console/Application.php index 07e9dbb317b..0ed436fb0e6 100644 --- a/lib/private/Console/Application.php +++ b/lib/private/Console/Application.php @@ -112,7 +112,7 @@ class Application { try { require_once __DIR__ . '/../../../core/register_command.php'; - if ($this->config->getSystemValue('installed', false)) { + if ($this->config->getSystemValueBool('installed', false)) { if (\OCP\Util::needUpgrade()) { throw new NeedsUpdateException(); } elseif ($this->config->getSystemValueBool('maintenance')) { diff --git a/lib/private/DB/Migrator.php b/lib/private/DB/Migrator.php index 97d91e1c100..74e5a285351 100644 --- a/lib/private/DB/Migrator.php +++ b/lib/private/DB/Migrator.php @@ -178,7 +178,7 @@ class Migrator { } protected function getFilterExpression() { - return '/^' . preg_quote($this->config->getSystemValue('dbtableprefix', 'oc_')) . '/'; + return '/^' . preg_quote($this->config->getSystemValueString('dbtableprefix', 'oc_')) . '/'; } protected function emit(string $sql, int $step, int $max): void { diff --git a/lib/private/DB/OracleMigrator.php b/lib/private/DB/OracleMigrator.php index db9fc33f07f..18deb97ec26 100644 --- a/lib/private/DB/OracleMigrator.php +++ b/lib/private/DB/OracleMigrator.php @@ -216,6 +216,6 @@ class OracleMigrator extends Migrator { } protected function getFilterExpression() { - return '/^"' . preg_quote($this->config->getSystemValue('dbtableprefix', 'oc_')) . '/'; + return '/^"' . preg_quote($this->config->getSystemValueString('dbtableprefix', 'oc_')) . '/'; } } diff --git a/lib/private/DB/PgSqlTools.php b/lib/private/DB/PgSqlTools.php index 2781d3556e2..af385eb5136 100644 --- a/lib/private/DB/PgSqlTools.php +++ b/lib/private/DB/PgSqlTools.php @@ -53,7 +53,7 @@ class PgSqlTools { $databaseName = $conn->getDatabase(); $conn->getConfiguration()->setSchemaAssetsFilter(function ($asset) { /** @var string|AbstractAsset $asset */ - $filterExpression = '/^' . preg_quote($this->config->getSystemValue('dbtableprefix', 'oc_')) . '/'; + $filterExpression = '/^' . preg_quote($this->config->getSystemValueString('dbtableprefix', 'oc_')) . '/'; if ($asset instanceof AbstractAsset) { return preg_match($filterExpression, $asset->getName()) !== false; } diff --git a/lib/private/Encryption/Keys/Storage.php b/lib/private/Encryption/Keys/Storage.php index b6376dc0146..e88c305eeec 100644 --- a/lib/private/Encryption/Keys/Storage.php +++ b/lib/private/Encryption/Keys/Storage.php @@ -237,7 +237,7 @@ class Storage implements IStorage { if (!array_key_exists('uid', $data) || $data['uid'] !== $uid) { // If the migration is done we error out - $versionFromBeforeUpdate = $this->config->getSystemValue('version', '0.0.0.0'); + $versionFromBeforeUpdate = $this->config->getSystemValueString('version', '0.0.0.0'); if (version_compare($versionFromBeforeUpdate, '20.0.0.1', '<=')) { return $data['key']; } @@ -272,7 +272,7 @@ class Storage implements IStorage { $data = $this->view->file_get_contents($path); // Version <20.0.0.1 doesn't have this - $versionFromBeforeUpdate = $this->config->getSystemValue('version', '0.0.0.0'); + $versionFromBeforeUpdate = $this->config->getSystemValueString('version', '0.0.0.0'); if (version_compare($versionFromBeforeUpdate, '20.0.0.1', '<=')) { $key = [ 'key' => base64_encode($data), @@ -335,7 +335,7 @@ class Storage implements IStorage { private function setKey($path, $key) { $this->keySetPreparation(dirname($path)); - $versionFromBeforeUpdate = $this->config->getSystemValue('version', '0.0.0.0'); + $versionFromBeforeUpdate = $this->config->getSystemValueString('version', '0.0.0.0'); if (version_compare($versionFromBeforeUpdate, '20.0.0.1', '<=')) { // Only store old format if this happens during the migration. // TODO: Remove for 21 diff --git a/lib/private/Encryption/Manager.php b/lib/private/Encryption/Manager.php index a553d6a55d1..f751bd94b28 100644 --- a/lib/private/Encryption/Manager.php +++ b/lib/private/Encryption/Manager.php @@ -73,7 +73,7 @@ class Manager implements IManager { * @return bool true if enabled, false if not */ public function isEnabled() { - $installed = $this->config->getSystemValue('installed', false); + $installed = $this->config->getSystemValueBool('installed', false); if (!$installed) { return false; } diff --git a/lib/private/Encryption/Util.php b/lib/private/Encryption/Util.php index 371f2588289..6ae0006e955 100644 --- a/lib/private/Encryption/Util.php +++ b/lib/private/Encryption/Util.php @@ -70,7 +70,7 @@ class Util { protected $config; /** @var array paths excluded from encryption */ - protected $excludedPaths; + protected array $excludedPaths = []; protected IGroupManager $groupManager; protected IUserManager $userManager; @@ -94,7 +94,7 @@ class Util { $this->config = $config; $this->excludedPaths[] = 'files_encryption'; - $this->excludedPaths[] = 'appdata_' . $config->getSystemValue('instanceid', null); + $this->excludedPaths[] = 'appdata_' . $config->getSystemValueString('instanceid'); $this->excludedPaths[] = 'files_external'; } diff --git a/lib/private/Files/Cache/Scanner.php b/lib/private/Files/Cache/Scanner.php index f7d1d105d83..05e24287a7d 100644 --- a/lib/private/Files/Cache/Scanner.php +++ b/lib/private/Files/Cache/Scanner.php @@ -91,7 +91,7 @@ class Scanner extends BasicEmitter implements IScanner { $this->storage = $storage; $this->storageId = $this->storage->getId(); $this->cache = $storage->getCache(); - $this->cacheActive = !\OC::$server->getConfig()->getSystemValue('filesystem_cache_readonly', false); + $this->cacheActive = !\OC::$server->getConfig()->getSystemValueBool('filesystem_cache_readonly', false); $this->lockingProvider = \OC::$server->getLockingProvider(); } @@ -219,7 +219,7 @@ class Scanner extends BasicEmitter implements IScanner { $newData['parent'] = $parentId; $data['fileid'] = $this->addToCache($file, $newData, $fileId); } - + $data['oldSize'] = ($cacheData && isset($cacheData['size'])) ? $cacheData['size'] : 0; if ($cacheData && isset($cacheData['encrypted'])) { diff --git a/lib/private/Files/Mount/CacheMountProvider.php b/lib/private/Files/Mount/CacheMountProvider.php index 90dfa0b05f3..903b93276c0 100644 --- a/lib/private/Files/Mount/CacheMountProvider.php +++ b/lib/private/Files/Mount/CacheMountProvider.php @@ -52,7 +52,7 @@ class CacheMountProvider implements IMountProvider { * @return \OCP\Files\Mount\IMountPoint[] */ public function getMountsForUser(IUser $user, IStorageFactory $loader) { - $cacheBaseDir = $this->config->getSystemValue('cache_path', ''); + $cacheBaseDir = $this->config->getSystemValueString('cache_path', ''); if ($cacheBaseDir !== '') { $cacheDir = rtrim($cacheBaseDir, '/') . '/' . $user->getUID(); if (!file_exists($cacheDir)) { diff --git a/lib/private/Files/Storage/Common.php b/lib/private/Files/Storage/Common.php index 3473eebc4a0..b202c70b3ad 100644 --- a/lib/private/Files/Storage/Common.php +++ b/lib/private/Files/Storage/Common.php @@ -834,7 +834,7 @@ abstract class Common implements Storage, ILockingStorage, IWriteStreamStorage { private function getLockLogger(): ?LoggerInterface { if (is_null($this->shouldLogLocks)) { - $this->shouldLogLocks = \OC::$server->getConfig()->getSystemValue('filelocking.debug', false); + $this->shouldLogLocks = \OC::$server->getConfig()->getSystemValueBool('filelocking.debug', false); $this->logger = $this->shouldLogLocks ? \OC::$server->get(LoggerInterface::class) : null; } return $this->logger; diff --git a/lib/private/Files/Storage/DAV.php b/lib/private/Files/Storage/DAV.php index 0c4a81b7491..9388e2b20a8 100644 --- a/lib/private/Files/Storage/DAV.php +++ b/lib/private/Files/Storage/DAV.php @@ -145,7 +145,7 @@ class DAV extends Common { $settings['authType'] = $this->authType; } - $proxy = \OC::$server->getConfig()->getSystemValue('proxy', ''); + $proxy = \OC::$server->getConfig()->getSystemValueString('proxy', ''); if ($proxy !== '') { $settings['proxy'] = $proxy; } diff --git a/lib/private/Files/Storage/Local.php b/lib/private/Files/Storage/Local.php index 448346e5622..c5f51897559 100644 --- a/lib/private/Files/Storage/Local.php +++ b/lib/private/Files/Storage/Local.php @@ -93,7 +93,7 @@ class Local extends \OC\Files\Storage\Common { $this->defUMask = $this->config->getSystemValue('localstorage.umask', 0022); // support Write-Once-Read-Many file systems - $this->unlinkOnTruncate = $this->config->getSystemValue('localstorage.unlink_on_truncate', false); + $this->unlinkOnTruncate = $this->config->getSystemValueBool('localstorage.unlink_on_truncate', false); } public function __destruct() { @@ -486,7 +486,7 @@ class Local extends \OC\Files\Storage\Common { $fullPath = $this->datadir . $path; $currentPath = $path; - $allowSymlinks = $this->config->getSystemValue('localstorage.allowsymlinks', false); + $allowSymlinks = $this->config->getSystemValueBool('localstorage.allowsymlinks', false); if ($allowSymlinks || $currentPath === '') { return $fullPath; } diff --git a/lib/private/Files/Template/TemplateManager.php b/lib/private/Files/Template/TemplateManager.php index 4603c14278f..bf72e9e23e8 100644 --- a/lib/private/Files/Template/TemplateManager.php +++ b/lib/private/Files/Template/TemplateManager.php @@ -268,8 +268,8 @@ class TemplateManager implements ITemplateManager { $defaultSkeletonDirectory = \OC::$SERVERROOT . '/core/skeleton'; $defaultTemplateDirectory = \OC::$SERVERROOT . '/core/skeleton/Templates'; - $skeletonPath = $this->config->getSystemValue('skeletondirectory', $defaultSkeletonDirectory); - $skeletonTemplatePath = $this->config->getSystemValue('templatedirectory', $defaultTemplateDirectory); + $skeletonPath = $this->config->getSystemValueString('skeletondirectory', $defaultSkeletonDirectory); + $skeletonTemplatePath = $this->config->getSystemValueString('templatedirectory', $defaultTemplateDirectory); $isDefaultSkeleton = $skeletonPath === $defaultSkeletonDirectory; $isDefaultTemplates = $skeletonTemplatePath === $defaultTemplateDirectory; $userLang = $this->l10nFactory->getUserLanguage($this->userManager->get($this->userId)); diff --git a/lib/private/GlobalScale/Config.php b/lib/private/GlobalScale/Config.php index a5449ade691..66abbfc15db 100644 --- a/lib/private/GlobalScale/Config.php +++ b/lib/private/GlobalScale/Config.php @@ -44,8 +44,7 @@ class Config implements \OCP\GlobalScale\IConfig { * @return bool */ public function isGlobalScaleEnabled() { - $enabled = $this->config->getSystemValue('gs.enabled', false); - return $enabled !== false; + return $this->config->getSystemValueBool('gs.enabled', false); } /** @@ -61,7 +60,7 @@ class Config implements \OCP\GlobalScale\IConfig { return false; } - $enabled = $this->config->getSystemValue('gs.federation', 'internal'); + $enabled = $this->config->getSystemValueString('gs.federation', 'internal'); return $enabled === 'internal'; } diff --git a/lib/private/Http/Client/Client.php b/lib/private/Http/Client/Client.php index 2e370395132..298749d52e1 100644 --- a/lib/private/Http/Client/Client.php +++ b/lib/private/Http/Client/Client.php @@ -122,7 +122,7 @@ class Client implements IClient { // If the instance is not yet setup we need to use the static path as // $this->certificateManager->getAbsoluteBundlePath() tries to instantiate // a view - if ($this->config->getSystemValue('installed', false) === false) { + if (!$this->config->getSystemValueBool('installed', false)) { return \OC::$SERVERROOT . '/resources/config/ca-bundle.crt'; } @@ -145,14 +145,14 @@ class Client implements IClient { * */ private function getProxyUri(): ?array { - $proxyHost = $this->config->getSystemValue('proxy', ''); + $proxyHost = $this->config->getSystemValueString('proxy', ''); - if ($proxyHost === '' || $proxyHost === null) { + if ($proxyHost === '') { return null; } - $proxyUserPwd = $this->config->getSystemValue('proxyuserpwd', ''); - if ($proxyUserPwd !== '' && $proxyUserPwd !== null) { + $proxyUserPwd = $this->config->getSystemValueString('proxyuserpwd', ''); + if ($proxyUserPwd !== '') { $proxyHost = $proxyUserPwd . '@' . $proxyHost; } diff --git a/lib/private/IntegrityCheck/Checker.php b/lib/private/IntegrityCheck/Checker.php index 9587e0fd42a..94e82223168 100644 --- a/lib/private/IntegrityCheck/Checker.php +++ b/lib/private/IntegrityCheck/Checker.php @@ -116,9 +116,9 @@ class Checker { */ $isIntegrityCheckDisabled = false; if ($this->config !== null) { - $isIntegrityCheckDisabled = $this->config->getSystemValue('integrity.check.disabled', false); + $isIntegrityCheckDisabled = $this->config->getSystemValueBool('integrity.check.disabled', false); } - if ($isIntegrityCheckDisabled === true) { + if ($isIntegrityCheckDisabled) { return false; } diff --git a/lib/private/IntegrityCheck/Iterator/ExcludeFoldersByPathFilterIterator.php b/lib/private/IntegrityCheck/Iterator/ExcludeFoldersByPathFilterIterator.php index 120791f5b03..a0b48158b9f 100644 --- a/lib/private/IntegrityCheck/Iterator/ExcludeFoldersByPathFilterIterator.php +++ b/lib/private/IntegrityCheck/Iterator/ExcludeFoldersByPathFilterIterator.php @@ -51,7 +51,7 @@ class ExcludeFoldersByPathFilterIterator extends \RecursiveFilterIterator { rtrim($root . '/updater', '/'), rtrim($root . '/_oc_upgrade', '/'), ]; - $customDataDir = \OC::$server->getConfig()->getSystemValue('datadirectory', ''); + $customDataDir = \OC::$server->getConfig()->getSystemValueString('datadirectory', ''); if ($customDataDir !== '') { $excludedFolders[] = rtrim($customDataDir, '/'); } diff --git a/lib/private/L10N/Factory.php b/lib/private/L10N/Factory.php index 593af02bd1c..1082662933f 100644 --- a/lib/private/L10N/Factory.php +++ b/lib/private/L10N/Factory.php @@ -195,7 +195,7 @@ class Factory implements IFactory { * * @link https://github.com/owncloud/core/issues/21955 */ - if ($this->config->getSystemValue('installed', false)) { + if ($this->config->getSystemValueBool('installed', false)) { $userId = !is_null($this->userSession->getUser()) ? $this->userSession->getUser()->getUID() : null; if (!is_null($userId)) { $userLang = $this->config->getUserValue($userId, 'core', 'lang', null); @@ -247,7 +247,7 @@ class Factory implements IFactory { } // Step 3.1: Check if Nextcloud is already installed before we try to access user info - if (!$this->config->getSystemValue('installed', false)) { + if (!$this->config->getSystemValueBool('installed', false)) { return 'en'; } // Step 3.2: Check the current user (if any) for their preferred language @@ -282,7 +282,7 @@ class Factory implements IFactory { return $forceLocale; } - if ($this->config->getSystemValue('installed', false)) { + if ($this->config->getSystemValueBool('installed', false)) { $userId = null !== $this->userSession->getUser() ? $this->userSession->getUser()->getUID() : null; $userLocale = null; if (null !== $userId) { @@ -366,7 +366,7 @@ class Factory implements IFactory { } // merge with translations from theme - $theme = $this->config->getSystemValue('theme'); + $theme = $this->config->getSystemValueString('theme'); if (!empty($theme)) { $themeDir = $this->serverRoot . '/themes/' . $theme . substr($dir, strlen($this->serverRoot)); @@ -452,7 +452,7 @@ class Factory implements IFactory { } } - return $this->config->getSystemValue('default_language', 'en'); + return $this->config->getSystemValueString('default_language', 'en'); } /** @@ -576,7 +576,7 @@ class Factory implements IFactory { } // merge with translations from theme - $theme = $this->config->getSystemValue('theme'); + $theme = $this->config->getSystemValueString('theme'); if (!empty($theme)) { $transFile = $this->serverRoot . '/themes/' . $theme . substr($transFile, strlen($this->serverRoot)); if (file_exists($transFile)) { diff --git a/lib/private/L10N/LanguageIterator.php b/lib/private/L10N/LanguageIterator.php index b3549782d54..b5f060d7db1 100644 --- a/lib/private/L10N/LanguageIterator.php +++ b/lib/private/L10N/LanguageIterator.php @@ -93,7 +93,7 @@ class LanguageIterator implements ILanguageIterator { $this->next(); // no break case 4: - return $this->config->getSystemValue('default_language', 'en'); + return $this->config->getSystemValueString('default_language', 'en'); /** @noinspection PhpMissingBreakStatementInspection */ case 5: $defaultLang = $this->config->getSystemValue('default_language', 'en'); diff --git a/lib/private/Log/Rotate.php b/lib/private/Log/Rotate.php index 20bc3327f92..dfb588837f3 100644 --- a/lib/private/Log/Rotate.php +++ b/lib/private/Log/Rotate.php @@ -39,7 +39,7 @@ class Rotate extends \OCP\BackgroundJob\Job { $systemConfig = \OC::$server->getSystemConfig(); $this->filePath = $systemConfig->getValue('logfile', $systemConfig->getValue('datadirectory', \OC::$SERVERROOT . '/data') . '/nextcloud.log'); - $this->maxSize = \OC::$server->getConfig()->getSystemValue('log_rotate_size', 100 * 1024 * 1024); + $this->maxSize = \OC::$server->getConfig()->getSystemValueInt('log_rotate_size', 100 * 1024 * 1024); if ($this->shouldRotateBySize()) { $rotatedFile = $this->rotate(); $msg = 'Log file "'.$this->filePath.'" was over '.$this->maxSize.' bytes, moved to "'.$rotatedFile.'"'; diff --git a/lib/private/Mail/Mailer.php b/lib/private/Mail/Mailer.php index 05ef0bf5139..5d838b2cdf1 100644 --- a/lib/private/Mail/Mailer.php +++ b/lib/private/Mail/Mailer.php @@ -57,7 +57,6 @@ use Symfony\Component\Mailer\Transport\SendmailTransport; use Symfony\Component\Mailer\Transport\Smtp\EsmtpTransport; use Symfony\Component\Mailer\Transport\Smtp\Stream\SocketStream; use Symfony\Component\Mime\Email; -use Symfony\Component\Mime\Exception\InvalidArgumentException; use Symfony\Component\Mime\Exception\RfcComplianceException; /** @@ -110,7 +109,7 @@ class Mailer implements IMailer { * @return Message */ public function createMessage(): Message { - $plainTextOnly = $this->config->getSystemValue('mail_send_plaintext_only', false); + $plainTextOnly = $this->config->getSystemValueBool('mail_send_plaintext_only', false); return new Message(new Email(), $plainTextOnly); } @@ -144,7 +143,7 @@ class Mailer implements IMailer { * @since 12.0.0 */ public function createEMailTemplate(string $emailId, array $data = []): IEMailTemplate { - $class = $this->config->getSystemValue('mail_template_class', ''); + $class = $this->config->getSystemValueString('mail_template_class', ''); if ($class !== '' && class_exists($class) && is_a($class, EMailTemplate::class, true)) { return new $class( @@ -176,10 +175,10 @@ class Mailer implements IMailer { * @return string[] $failedRecipients */ public function send(IMessage $message): array { - $debugMode = $this->config->getSystemValue('mail_smtpdebug', false); + $debugMode = $this->config->getSystemValueBool('mail_smtpdebug', false); if (!($message instanceof Message)) { - throw new InvalidArgumentException('Object not of type ' . Message::class); + throw new \InvalidArgumentException('Object not of type ' . Message::class); } if (empty($message->getFrom())) { @@ -192,7 +191,7 @@ class Mailer implements IMailer { try { $message->setRecipients(); - } catch (InvalidArgumentException|RfcComplianceException $e) { + } catch (\InvalidArgumentException|RfcComplianceException $e) { $logMessage = sprintf( 'Could not send mail to "%s" with subject "%s" as validation for address failed', print_r(array_merge($message->getTo(), $message->getCc(), $message->getBcc()), true), @@ -267,7 +266,7 @@ class Mailer implements IMailer { $transport = null; - switch ($this->config->getSystemValue('mail_smtpmode', 'smtp')) { + switch ($this->config->getSystemValueString('mail_smtpmode', 'smtp')) { case 'sendmail': $transport = $this->getSendMailInstance(); break; @@ -294,7 +293,7 @@ class Mailer implements IMailer { $mailSmtpsecure = ($this->config->getSystemValue('mail_smtpsecure', null) === 'ssl') ? true : null; $transport = new EsmtpTransport( $this->config->getSystemValue('mail_smtphost', '127.0.0.1'), - (int)$this->config->getSystemValue('mail_smtpport', 25), + $this->config->getSystemValueInt('mail_smtpport', 25), $mailSmtpsecure, null, $this->logger @@ -304,7 +303,7 @@ class Mailer implements IMailer { /** @psalm-suppress InternalMethod */ $stream->setTimeout($this->config->getSystemValue('mail_smtptimeout', 10)); - if ($this->config->getSystemValue('mail_smtpauth', false)) { + if ($this->config->getSystemValueBool('mail_smtpauth', false)) { $transport->setUsername($this->config->getSystemValue('mail_smtpname', '')); $transport->setPassword($this->config->getSystemValue('mail_smtppassword', '')); } @@ -338,7 +337,7 @@ class Mailer implements IMailer { * @return SendmailTransport */ protected function getSendMailInstance(): SendmailTransport { - switch ($this->config->getSystemValue('mail_smtpmode', 'smtp')) { + switch ($this->config->getSystemValueString('mail_smtpmode', 'smtp')) { case 'qmail': $binaryPath = '/var/qmail/bin/sendmail'; break; @@ -351,7 +350,7 @@ class Mailer implements IMailer { break; } - switch ($this->config->getSystemValue('mail_sendmailmode', 'smtp')) { + switch ($this->config->getSystemValueString('mail_sendmailmode', 'smtp')) { case 'pipe': $binaryParam = ' -t'; break; diff --git a/lib/private/NavigationManager.php b/lib/private/NavigationManager.php index 2050244d384..56f55e80331 100644 --- a/lib/private/NavigationManager.php +++ b/lib/private/NavigationManager.php @@ -189,7 +189,7 @@ class NavigationManager implements INavigationManager { $this->init = true; $l = $this->l10nFac->get('lib'); - if ($this->config->getSystemValue('knowledgebaseenabled', true)) { + if ($this->config->getSystemValueBool('knowledgebaseenabled', true)) { $this->add([ 'type' => 'settings', 'id' => 'help', diff --git a/lib/private/Preview/Imaginary.php b/lib/private/Preview/Imaginary.php index ca46383e58b..962e5663b39 100644 --- a/lib/private/Preview/Imaginary.php +++ b/lib/private/Preview/Imaginary.php @@ -61,7 +61,7 @@ class Imaginary extends ProviderV2 { } public function getCroppedThumbnail(File $file, int $maxX, int $maxY, bool $crop): ?IImage { - $maxSizeForImages = $this->config->getSystemValue('preview_max_filesize_image', 50); + $maxSizeForImages = $this->config->getSystemValueInt('preview_max_filesize_image', 50); $size = $file->getSize(); @@ -105,7 +105,7 @@ class Imaginary extends ProviderV2 { default: $mimeType = 'jpeg'; } - + $operations = []; if ($convert) { diff --git a/lib/private/PreviewManager.php b/lib/private/PreviewManager.php index dd6b6ba8ee1..140dfefc93d 100644 --- a/lib/private/PreviewManager.php +++ b/lib/private/PreviewManager.php @@ -113,7 +113,7 @@ class PreviewManager implements IPreview { * @return void */ public function registerProvider($mimeTypeRegex, \Closure $callable): void { - if (!$this->config->getSystemValue('enable_previews', true)) { + if (!$this->config->getSystemValueBool('enable_previews', true)) { return; } diff --git a/lib/private/Repair/ClearGeneratedAvatarCache.php b/lib/private/Repair/ClearGeneratedAvatarCache.php index db86d92cd87..844bf6cf346 100644 --- a/lib/private/Repair/ClearGeneratedAvatarCache.php +++ b/lib/private/Repair/ClearGeneratedAvatarCache.php @@ -49,7 +49,7 @@ class ClearGeneratedAvatarCache implements IRepairStep { * Check if this repair step should run */ private function shouldRun(): bool { - $versionFromBeforeUpdate = $this->config->getSystemValue('version', '0.0.0.0'); + $versionFromBeforeUpdate = $this->config->getSystemValueString('version', '0.0.0.0'); // was added to 25.0.0.10 return version_compare($versionFromBeforeUpdate, '25.0.0.10', '<='); diff --git a/lib/private/Repair/Collation.php b/lib/private/Repair/Collation.php index 25e85f00af8..6f7dde68865 100644 --- a/lib/private/Repair/Collation.php +++ b/lib/private/Repair/Collation.php @@ -74,7 +74,7 @@ class Collation implements IRepairStep { return; } - $characterSet = $this->config->getSystemValue('mysql.utf8mb4', false) ? 'utf8mb4' : 'utf8'; + $characterSet = $this->config->getSystemValueBool('mysql.utf8mb4', false) ? 'utf8mb4' : 'utf8'; $tables = $this->getAllNonUTF8BinTables($this->connection); foreach ($tables as $table) { @@ -112,8 +112,8 @@ class Collation implements IRepairStep { * @return string[] */ protected function getAllNonUTF8BinTables(IDBConnection $connection) { - $dbName = $this->config->getSystemValue("dbname"); - $characterSet = $this->config->getSystemValue('mysql.utf8mb4', false) ? 'utf8mb4' : 'utf8'; + $dbName = $this->config->getSystemValueString("dbname"); + $characterSet = $this->config->getSystemValueBool('mysql.utf8mb4', false) ? 'utf8mb4' : 'utf8'; // fetch tables by columns $statement = $connection->executeQuery( diff --git a/lib/private/Repair/MoveUpdaterStepFile.php b/lib/private/Repair/MoveUpdaterStepFile.php index 905fc9451f5..fc3b9dce1f3 100644 --- a/lib/private/Repair/MoveUpdaterStepFile.php +++ b/lib/private/Repair/MoveUpdaterStepFile.php @@ -43,9 +43,9 @@ class MoveUpdaterStepFile implements IRepairStep { public function run(IOutput $output) { $updateDir = $this->config->getSystemValue('updatedirectory', null) ?? $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data'); - $instanceId = $this->config->getSystemValue('instanceid', null); + $instanceId = $this->config->getSystemValueString('instanceid'); - if (!is_string($instanceId) || empty($instanceId)) { + if (empty($instanceId)) { return; } diff --git a/lib/private/Repair/NC16/CleanupCardDAVPhotoCache.php b/lib/private/Repair/NC16/CleanupCardDAVPhotoCache.php index b12604cd132..394e47dfcda 100644 --- a/lib/private/Repair/NC16/CleanupCardDAVPhotoCache.php +++ b/lib/private/Repair/NC16/CleanupCardDAVPhotoCache.php @@ -96,7 +96,7 @@ class CleanupCardDAVPhotoCache implements IRepairStep { private function shouldRun(): bool { return version_compare( - $this->config->getSystemValue('version', '0.0.0.0'), + $this->config->getSystemValueString('version', '0.0.0.0'), '16.0.0.0', '<=' ); diff --git a/lib/private/Repair/NC16/ClearCollectionsAccessCache.php b/lib/private/Repair/NC16/ClearCollectionsAccessCache.php index 51a63406d22..076e27a6ceb 100644 --- a/lib/private/Repair/NC16/ClearCollectionsAccessCache.php +++ b/lib/private/Repair/NC16/ClearCollectionsAccessCache.php @@ -48,7 +48,7 @@ class ClearCollectionsAccessCache implements IRepairStep { } private function shouldRun(): bool { - $versionFromBeforeUpdate = $this->config->getSystemValue('version', '0.0.0.0'); + $versionFromBeforeUpdate = $this->config->getSystemValueString('version', '0.0.0.0'); return version_compare($versionFromBeforeUpdate, '17.0.0.3', '<='); } diff --git a/lib/private/Repair/NC18/ResetGeneratedAvatarFlag.php b/lib/private/Repair/NC18/ResetGeneratedAvatarFlag.php index 3635c86e1b9..d5ae1d7ab63 100644 --- a/lib/private/Repair/NC18/ResetGeneratedAvatarFlag.php +++ b/lib/private/Repair/NC18/ResetGeneratedAvatarFlag.php @@ -47,7 +47,7 @@ class ResetGeneratedAvatarFlag implements IRepairStep { } private function shouldRun(): bool { - $versionFromBeforeUpdate = $this->config->getSystemValue('version', '0.0.0.0'); + $versionFromBeforeUpdate = $this->config->getSystemValueString('version', '0.0.0.0'); return version_compare($versionFromBeforeUpdate, '18.0.0.5', '<='); } diff --git a/lib/private/Repair/NC20/EncryptionLegacyCipher.php b/lib/private/Repair/NC20/EncryptionLegacyCipher.php index 6e31423915f..a7d008e87be 100644 --- a/lib/private/Repair/NC20/EncryptionLegacyCipher.php +++ b/lib/private/Repair/NC20/EncryptionLegacyCipher.php @@ -48,7 +48,7 @@ class EncryptionLegacyCipher implements IRepairStep { } private function shouldRun(): bool { - $versionFromBeforeUpdate = $this->config->getSystemValue('version', '0.0.0.0'); + $versionFromBeforeUpdate = $this->config->getSystemValueString('version', '0.0.0.0'); return version_compare($versionFromBeforeUpdate, '20.0.0.0', '<='); } diff --git a/lib/private/Repair/NC20/EncryptionMigration.php b/lib/private/Repair/NC20/EncryptionMigration.php index 6e209314462..239a62c2718 100644 --- a/lib/private/Repair/NC20/EncryptionMigration.php +++ b/lib/private/Repair/NC20/EncryptionMigration.php @@ -48,7 +48,7 @@ class EncryptionMigration implements IRepairStep { } private function shouldRun(): bool { - $versionFromBeforeUpdate = $this->config->getSystemValue('version', '0.0.0.0'); + $versionFromBeforeUpdate = $this->config->getSystemValueString('version', '0.0.0.0'); return version_compare($versionFromBeforeUpdate, '20.0.0.1', '<='); } diff --git a/lib/private/Repair/NC21/AddCheckForUserCertificatesJob.php b/lib/private/Repair/NC21/AddCheckForUserCertificatesJob.php index e9b26947db6..ee413ce12ca 100644 --- a/lib/private/Repair/NC21/AddCheckForUserCertificatesJob.php +++ b/lib/private/Repair/NC21/AddCheckForUserCertificatesJob.php @@ -44,7 +44,7 @@ class AddCheckForUserCertificatesJob implements IRepairStep { } private function shouldRun() { - $versionFromBeforeUpdate = $this->config->getSystemValue('version', '0.0.0.0'); + $versionFromBeforeUpdate = $this->config->getSystemValueString('version', '0.0.0.0'); // was added to 21.0.0.2 return version_compare($versionFromBeforeUpdate, '21.0.0.2', '<'); diff --git a/lib/private/Repair/NC22/LookupServerSendCheck.php b/lib/private/Repair/NC22/LookupServerSendCheck.php index 46029357dbe..93475d88a2d 100644 --- a/lib/private/Repair/NC22/LookupServerSendCheck.php +++ b/lib/private/Repair/NC22/LookupServerSendCheck.php @@ -46,7 +46,7 @@ class LookupServerSendCheck implements IRepairStep { } private function shouldRun(): bool { - $versionFromBeforeUpdate = $this->config->getSystemValue('version', '0.0.0.0'); + $versionFromBeforeUpdate = $this->config->getSystemValueString('version', '0.0.0.0'); // was added to 22.0.0.3 return (version_compare($versionFromBeforeUpdate, '22.0.0.3', '<') && version_compare($versionFromBeforeUpdate, '22.0.0.0', '>=')) diff --git a/lib/private/Repair/NC25/AddMissingSecretJob.php b/lib/private/Repair/NC25/AddMissingSecretJob.php index 1194fe3f6ab..d3a438b89c1 100644 --- a/lib/private/Repair/NC25/AddMissingSecretJob.php +++ b/lib/private/Repair/NC25/AddMissingSecretJob.php @@ -42,8 +42,8 @@ class AddMissingSecretJob implements IRepairStep { } public function run(IOutput $output): void { - $passwordSalt = $this->config->getSystemValue('passwordsalt', null); - if ($passwordSalt === null || $passwordSalt === '') { + $passwordSalt = $this->config->getSystemValueString('passwordsalt', ''); + if ($passwordSalt === '') { try { $this->config->setSystemValue('passwordsalt', $this->random->generate(30)); } catch (HintException $e) { @@ -51,8 +51,8 @@ class AddMissingSecretJob implements IRepairStep { } } - $secret = $this->config->getSystemValue('secret', null); - if ($secret === null || $secret === '') { + $secret = $this->config->getSystemValueString('secret', ''); + if ($secret === '') { try { $this->config->setSystemValue('secret', $this->random->generate(48)); } catch (HintException $e) { diff --git a/lib/private/Repair/Owncloud/MoveAvatars.php b/lib/private/Repair/Owncloud/MoveAvatars.php index fa3dd924648..44ba9b7643b 100644 --- a/lib/private/Repair/Owncloud/MoveAvatars.php +++ b/lib/private/Repair/Owncloud/MoveAvatars.php @@ -59,7 +59,7 @@ class MoveAvatars implements IRepairStep { $output->info('Repair step already executed'); return; } - if ($this->config->getSystemValue('enable_avatars', true) === false) { + if (!$this->config->getSystemValueBool('enable_avatars', true)) { $output->info('Avatars are disabled'); } else { $output->info('Add background job'); diff --git a/lib/private/Repair/Owncloud/SaveAccountsTableData.php b/lib/private/Repair/Owncloud/SaveAccountsTableData.php index 13677d80de0..94fd1554293 100644 --- a/lib/private/Repair/Owncloud/SaveAccountsTableData.php +++ b/lib/private/Repair/Owncloud/SaveAccountsTableData.php @@ -79,7 +79,7 @@ class SaveAccountsTableData implements IRepairStep { } // oc_persistent_locks will be removed later on anyways so we can just drop and ignore any foreign key constraints here - $tableName = $this->config->getSystemValue('dbtableprefix', 'oc_') . 'persistent_locks'; + $tableName = $this->config->getSystemValueString('dbtableprefix', 'oc_') . 'persistent_locks'; $schema = $this->db->createSchema(); $table = $schema->getTable($tableName); foreach ($table->getForeignKeys() as $foreignKey) { @@ -99,7 +99,7 @@ class SaveAccountsTableData implements IRepairStep { */ protected function shouldRun() { $schema = $this->db->createSchema(); - $prefix = $this->config->getSystemValue('dbtableprefix', 'oc_'); + $prefix = $this->config->getSystemValueString('dbtableprefix', 'oc_'); $tableName = $prefix . 'accounts'; if (!$schema->hasTable($tableName)) { diff --git a/lib/private/Repair/Owncloud/UpdateLanguageCodes.php b/lib/private/Repair/Owncloud/UpdateLanguageCodes.php index cb4525b6c1d..e08a0b55a9a 100644 --- a/lib/private/Repair/Owncloud/UpdateLanguageCodes.php +++ b/lib/private/Repair/Owncloud/UpdateLanguageCodes.php @@ -56,7 +56,7 @@ class UpdateLanguageCodes implements IRepairStep { * {@inheritdoc} */ public function run(IOutput $output) { - $versionFromBeforeUpdate = $this->config->getSystemValue('version', '0.0.0'); + $versionFromBeforeUpdate = $this->config->getSystemValueString('version', '0.0.0'); if (version_compare($versionFromBeforeUpdate, '12.0.0.13', '>')) { return; diff --git a/lib/private/Repair/RemoveLinkShares.php b/lib/private/Repair/RemoveLinkShares.php index 71eead1053b..b45a1d83a56 100644 --- a/lib/private/Repair/RemoveLinkShares.php +++ b/lib/private/Repair/RemoveLinkShares.php @@ -71,7 +71,7 @@ class RemoveLinkShares implements IRepairStep { } private function shouldRun(): bool { - $versionFromBeforeUpdate = $this->config->getSystemValue('version', '0.0.0'); + $versionFromBeforeUpdate = $this->config->getSystemValueString('version', '0.0.0'); if (version_compare($versionFromBeforeUpdate, '14.0.11', '<')) { return true; diff --git a/lib/private/Repair/RepairDavShares.php b/lib/private/Repair/RepairDavShares.php index 9c0bce66ae8..467adc2b0d9 100644 --- a/lib/private/Repair/RepairDavShares.php +++ b/lib/private/Repair/RepairDavShares.php @@ -125,7 +125,7 @@ class RepairDavShares implements IRepairStep { * @inheritDoc */ public function run(IOutput $output) { - $versionFromBeforeUpdate = $this->config->getSystemValue('version', '0.0.0'); + $versionFromBeforeUpdate = $this->config->getSystemValueString('version', '0.0.0'); if (version_compare($versionFromBeforeUpdate, '20.0.8', '<') && $this->repairUnencodedGroupShares() ) { diff --git a/lib/private/Repair/RepairInvalidShares.php b/lib/private/Repair/RepairInvalidShares.php index c34d5d9e005..9255034f6fe 100644 --- a/lib/private/Repair/RepairInvalidShares.php +++ b/lib/private/Repair/RepairInvalidShares.php @@ -110,7 +110,7 @@ class RepairInvalidShares implements IRepairStep { } public function run(IOutput $out) { - $ocVersionFromBeforeUpdate = $this->config->getSystemValue('version', '0.0.0'); + $ocVersionFromBeforeUpdate = $this->config->getSystemValueString('version', '0.0.0'); if (version_compare($ocVersionFromBeforeUpdate, '12.0.0.11', '<')) { $this->adjustFileSharePermissions($out); } diff --git a/lib/private/Repair/RepairMimeTypes.php b/lib/private/Repair/RepairMimeTypes.php index 5f3531ea79c..ee5a84ad65c 100644 --- a/lib/private/Repair/RepairMimeTypes.php +++ b/lib/private/Repair/RepairMimeTypes.php @@ -234,7 +234,7 @@ class RepairMimeTypes implements IRepairStep { * Fix mime types */ public function run(IOutput $out) { - $ocVersionFromBeforeUpdate = $this->config->getSystemValue('version', '0.0.0'); + $ocVersionFromBeforeUpdate = $this->config->getSystemValueString('version', '0.0.0'); // NOTE TO DEVELOPERS: when adding new mime types, please make sure to // add a version comparison to avoid doing it every time diff --git a/lib/private/Security/Bruteforce/Capabilities.php b/lib/private/Security/Bruteforce/Capabilities.php index 5de4f35f24e..60cf3086f2d 100644 --- a/lib/private/Security/Bruteforce/Capabilities.php +++ b/lib/private/Security/Bruteforce/Capabilities.php @@ -51,7 +51,7 @@ class Capabilities implements IPublicCapability, IInitialStateExcludedCapability } public function getCapabilities(): array { - if (version_compare(\OC::$server->getConfig()->getSystemValue('version', '0.0.0.0'), '12.0.0.0', '<')) { + if (version_compare(\OC::$server->getConfig()->getSystemValueString('version', '0.0.0.0'), '12.0.0.0', '<')) { return []; } diff --git a/lib/private/Security/Bruteforce/Throttler.php b/lib/private/Security/Bruteforce/Throttler.php index 299cab93eb3..d5fd0984baa 100644 --- a/lib/private/Security/Bruteforce/Throttler.php +++ b/lib/private/Security/Bruteforce/Throttler.php @@ -112,7 +112,7 @@ class Throttler implements IThrottler { string $ip, array $metadata = []): void { // No need to log if the bruteforce protection is disabled - if ($this->config->getSystemValue('auth.bruteforce.protection.enabled', true) === false) { + if (!$this->config->getSystemValueBool('auth.bruteforce.protection.enabled', true)) { return; } @@ -151,7 +151,7 @@ class Throttler implements IThrottler { * @return bool */ private function isIPWhitelisted(string $ip): bool { - if ($this->config->getSystemValue('auth.bruteforce.protection.enabled', true) === false) { + if (!$this->config->getSystemValueBool('auth.bruteforce.protection.enabled', true)) { return true; } diff --git a/lib/private/Security/CertificateManager.php b/lib/private/Security/CertificateManager.php index be884654bd0..ee68f602bd1 100644 --- a/lib/private/Security/CertificateManager.php +++ b/lib/private/Security/CertificateManager.php @@ -67,7 +67,7 @@ class CertificateManager implements ICertificateManager { * @return \OCP\ICertificate[] */ public function listCertificates(): array { - if (!$this->config->getSystemValue('installed', false)) { + if (!$this->config->getSystemValueBool('installed', false)) { return []; } @@ -93,7 +93,7 @@ class CertificateManager implements ICertificateManager { } private function hasCertificates(): bool { - if (!$this->config->getSystemValue('installed', false)) { + if (!$this->config->getSystemValueBool('installed', false)) { return false; } diff --git a/lib/private/Security/Crypto.php b/lib/private/Security/Crypto.php index aeeafcc271c..2a7905376ef 100644 --- a/lib/private/Security/Crypto.php +++ b/lib/private/Security/Crypto.php @@ -70,7 +70,7 @@ class Crypto implements ICrypto { */ public function calculateHMAC(string $message, string $password = ''): string { if ($password === '') { - $password = $this->config->getSystemValue('secret'); + $password = $this->config->getSystemValueString('secret'); } // Append an "a" behind the password and hash it to prevent reusing the same password as for encryption @@ -92,7 +92,7 @@ class Crypto implements ICrypto { */ public function encrypt(string $plaintext, string $password = ''): string { if ($password === '') { - $password = $this->config->getSystemValue('secret'); + $password = $this->config->getSystemValueString('secret'); } $keyMaterial = hash_hkdf('sha512', $password); $this->cipher->setPassword(substr($keyMaterial, 0, 32)); diff --git a/lib/private/Security/Hasher.php b/lib/private/Security/Hasher.php index 4731ba96bd3..85f69263925 100644 --- a/lib/private/Security/Hasher.php +++ b/lib/private/Security/Hasher.php @@ -209,7 +209,7 @@ class Hasher implements IHasher { } // Check if we should use PASSWORD_DEFAULT - if ($this->config->getSystemValue('hashing_default_password', false) === true) { + if ($this->config->getSystemValueBool('hashing_default_password', false)) { $default = PASSWORD_DEFAULT; } diff --git a/lib/private/Security/VerificationToken/VerificationToken.php b/lib/private/Security/VerificationToken/VerificationToken.php index 2d3f902b622..52c3f62b813 100644 --- a/lib/private/Security/VerificationToken/VerificationToken.php +++ b/lib/private/Security/VerificationToken/VerificationToken.php @@ -82,7 +82,7 @@ class VerificationToken implements IVerificationToken { } try { - $decryptedToken = $this->crypto->decrypt($encryptedToken, $passwordPrefix.$this->config->getSystemValue('secret')); + $decryptedToken = $this->crypto->decrypt($encryptedToken, $passwordPrefix.$this->config->getSystemValueString('secret')); } catch (\Exception $e) { // Retry with empty secret as a fallback for instances where the secret might not have been set by accident try { @@ -115,7 +115,7 @@ class VerificationToken implements IVerificationToken { ISecureRandom::CHAR_UPPER ); $tokenValue = $this->timeFactory->getTime() .':'. $token; - $encryptedValue = $this->crypto->encrypt($tokenValue, $passwordPrefix . $this->config->getSystemValue('secret')); + $encryptedValue = $this->crypto->encrypt($tokenValue, $passwordPrefix . $this->config->getSystemValueString('secret')); $this->config->setUserValue($user->getUID(), 'core', $subject, $encryptedValue); $jobArgs = json_encode([ 'userId' => $user->getUID(), diff --git a/lib/private/Server.php b/lib/private/Server.php index 78099f2a8d0..80e03771888 100644 --- a/lib/private/Server.php +++ b/lib/private/Server.php @@ -726,7 +726,7 @@ class Server extends ServerContainer implements IServerContainer { /** @var \OCP\IConfig $config */ $config = $c->get(\OCP\IConfig::class); - if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { + if ($config->getSystemValueBool('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { if (!$config->getSystemValueBool('log_query')) { $v = \OC_App::getAppVersions(); } else { @@ -988,7 +988,7 @@ class Server extends ServerContainer implements IServerContainer { /** @deprecated 20.0.0 */ $this->registerDeprecatedAlias('IniWrapper', IniGetWrapper::class); $this->registerService(IBus::class, function (ContainerInterface $c) { - $busClass = $c->get(\OCP\IConfig::class)->getSystemValue('commandbus'); + $busClass = $c->get(\OCP\IConfig::class)->getSystemValueString('commandbus'); if ($busClass) { [$app, $class] = explode('::', $busClass, 2); if ($c->get(IAppManager::class)->isInstalled($app)) { @@ -1107,8 +1107,8 @@ class Server extends ServerContainer implements IServerContainer { $this->registerService(ILockingProvider::class, function (ContainerInterface $c) { $ini = $c->get(IniGetWrapper::class); $config = $c->get(\OCP\IConfig::class); - $ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time'))); - if ($config->getSystemValue('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { + $ttl = $config->getSystemValueInt('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time'))); + if ($config->getSystemValueBool('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { /** @var \OC\Memcache\Factory $memcacheFactory */ $memcacheFactory = $c->get(ICacheFactory::class); $memcache = $memcacheFactory->createLocking('lock'); @@ -1208,7 +1208,7 @@ class Server extends ServerContainer implements IServerContainer { $classExists = false; } - if ($classExists && $c->get(\OCP\IConfig::class)->getSystemValue('installed', false) && $c->get(IAppManager::class)->isInstalled('theming') && $c->getTrustedDomainHelper()->isTrustedDomain($c->getRequest()->getInsecureServerHost())) { + if ($classExists && $c->get(\OCP\IConfig::class)->getSystemValueBool('installed', false) && $c->get(IAppManager::class)->isInstalled('theming') && $c->getTrustedDomainHelper()->isTrustedDomain($c->getRequest()->getInsecureServerHost())) { $imageManager = new ImageManager( $c->get(\OCP\IConfig::class), $c->getAppDataDir('theming'), diff --git a/lib/private/Setup.php b/lib/private/Setup.php index e8371ba8542..7567aaf14b1 100644 --- a/lib/private/Setup.php +++ b/lib/private/Setup.php @@ -410,7 +410,7 @@ class Setup { // create empty file in data dir, so we can later find // out that this is indeed an ownCloud data directory - file_put_contents($config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data') . '/.ocdata', ''); + file_put_contents($config->getSystemValueString('datadirectory', \OC::$SERVERROOT . '/data') . '/.ocdata', ''); // Update .htaccess files self::updateHtaccess(); @@ -585,7 +585,7 @@ class Setup { $content .= " IndexIgnore *\n"; $content .= ""; - $baseDir = \OC::$server->getConfig()->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data'); + $baseDir = \OC::$server->getConfig()->getSystemValueString('datadirectory', \OC::$SERVERROOT . '/data'); file_put_contents($baseDir . '/.htaccess', $content); file_put_contents($baseDir . '/index.html', ''); } diff --git a/lib/private/Share20/Manager.php b/lib/private/Share20/Manager.php index 26e5549ccff..732bd5bb97d 100644 --- a/lib/private/Share20/Manager.php +++ b/lib/private/Share20/Manager.php @@ -1179,7 +1179,7 @@ class Manager implements IManager { * Set the share's password expiration time */ private function setSharePasswordExpirationTime(IShare $share): void { - if (!$this->config->getSystemValue('sharing.enable_mail_link_password_expiration', false)) { + if (!$this->config->getSystemValueBool('sharing.enable_mail_link_password_expiration', false)) { // Sets password expiration date to NULL $share->setPasswordExpirationTime(); return; diff --git a/lib/private/Support/Subscription/Registry.php b/lib/private/Support/Subscription/Registry.php index 7aafa539a0b..eba76ca103e 100644 --- a/lib/private/Support/Subscription/Registry.php +++ b/lib/private/Support/Subscription/Registry.php @@ -176,7 +176,7 @@ class Registry implements IRegistry { } $userCount = $this->getUserCount(); - $hardUserLimit = $this->config->getSystemValue('one-click-instance.user-limit', 50); + $hardUserLimit = $this->config->getSystemValueInt('one-click-instance.user-limit', 50); $userLimitReached = $userCount >= $hardUserLimit; if ($userLimitReached && $notificationManager instanceof IManager) { diff --git a/lib/private/TemplateLayout.php b/lib/private/TemplateLayout.php index 123fd6debb5..52c60e58991 100644 --- a/lib/private/TemplateLayout.php +++ b/lib/private/TemplateLayout.php @@ -221,7 +221,7 @@ class TemplateLayout extends \OC_Template { // TODO: remove deprecated OC_Util injection $jsFiles = self::findJavascriptFiles(array_merge(\OC_Util::$scripts, Util::getScripts())); $this->assign('jsfiles', []); - if ($this->config->getSystemValue('installed', false) && $renderAs != TemplateResponse::RENDER_AS_ERROR) { + if ($this->config->getSystemValueBool('installed', false) && $renderAs != TemplateResponse::RENDER_AS_ERROR) { // this is on purpose outside of the if statement below so that the initial state is prefilled (done in the getConfig() call) // see https://github.com/nextcloud/server/pull/22636 for details $jsConfigHelper = new JSConfigHelper( @@ -304,14 +304,14 @@ class TemplateLayout extends \OC_Template { * @return string */ protected function getVersionHashSuffix($path = false, $file = false) { - if ($this->config->getSystemValue('debug', false)) { + if ($this->config->getSystemValueBool('debug', false)) { // allows chrome workspace mapping in debug mode return ""; } $themingSuffix = ''; $v = []; - if ($this->config->getSystemValue('installed', false)) { + if ($this->config->getSystemValueBool('installed', false)) { if (\OC::$server->getAppManager()->isInstalled('theming')) { $themingSuffix = '-' . $this->config->getAppValue('theming', 'cachebuster', '0'); } diff --git a/lib/private/URLGenerator.php b/lib/private/URLGenerator.php index a5a3609703b..2410b8a9147 100644 --- a/lib/private/URLGenerator.php +++ b/lib/private/URLGenerator.php @@ -141,7 +141,7 @@ class URLGenerator implements IURLGenerator { * Returns a url to the given app and file. */ public function linkTo(string $appName, string $file, array $args = []): string { - $frontControllerActive = ($this->config->getSystemValue('htaccess.IgnoreFrontController', false) === true || getenv('front_controller_active') === 'true'); + $frontControllerActive = ($this->config->getSystemValueBool('htaccess.IgnoreFrontController', false) || getenv('front_controller_active') === 'true'); if ($appName !== '') { $app_path = $this->getAppManager()->getAppPath($appName); @@ -214,7 +214,7 @@ class URLGenerator implements IURLGenerator { // Check if the app is in the app folder $path = ''; - $themingEnabled = $this->config->getSystemValue('installed', false) && $this->getAppManager()->isEnabledForUser('theming'); + $themingEnabled = $this->config->getSystemValueBool('installed', false) && $this->getAppManager()->isEnabledForUser('theming'); $themingImagePath = false; if ($themingEnabled) { $themingDefaults = \OC::$server->getThemingDefaults(); @@ -275,7 +275,7 @@ class URLGenerator implements IURLGenerator { $separator = strpos($url, '/') === 0 ? '' : '/'; if (\OC::$CLI && !\defined('PHPUNIT_RUN')) { - return rtrim($this->config->getSystemValue('overwrite.cli.url'), '/') . '/' . ltrim($url, '/'); + return rtrim($this->config->getSystemValueString('overwrite.cli.url'), '/') . '/' . ltrim($url, '/'); } // The ownCloud web root can already be prepended. if (\OC::$WEBROOT !== '' && strpos($url, \OC::$WEBROOT) === 0) { @@ -313,7 +313,7 @@ class URLGenerator implements IURLGenerator { $appId = $this->getAppManager()->getDefaultAppForUser(); - if ($this->config->getSystemValue('htaccess.IgnoreFrontController', false) === true + if ($this->config->getSystemValueBool('htaccess.IgnoreFrontController', false) || getenv('front_controller_active') === 'true') { return $this->getAbsoluteURL('/apps/' . $appId . '/'); } diff --git a/lib/private/Updater.php b/lib/private/Updater.php index 45c22dc89bc..075b2ce339b 100644 --- a/lib/private/Updater.php +++ b/lib/private/Updater.php @@ -129,7 +129,7 @@ class Updater extends BasicEmitter { } } - $installedVersion = $this->config->getSystemValue('version', '0.0.0'); + $installedVersion = $this->config->getSystemValueString('version', '0.0.0'); $currentVersion = implode('.', \OCP\Util::getVersion()); $this->log->debug('starting upgrade from ' . $installedVersion . ' to ' . $currentVersion, ['app' => 'core']); @@ -216,7 +216,7 @@ class Updater extends BasicEmitter { if ($currentVendor === 'nextcloud') { return isset($allowedPreviousVersions[$currentVendor][$majorMinor]) && (version_compare($oldVersion, $newVersion, '<=') || - $this->config->getSystemValue('debug', false)); + $this->config->getSystemValueBool('debug', false)); } // Check if the instance can be migrated @@ -251,7 +251,7 @@ class Updater extends BasicEmitter { // create empty file in data dir, so we can later find // out that this is indeed an ownCloud data directory // (in case it didn't exist before) - file_put_contents($this->config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data') . '/.ocdata', ''); + file_put_contents($this->config->getSystemValueString('datadirectory', \OC::$SERVERROOT . '/data') . '/.ocdata', ''); // pre-upgrade repairs $repair = new Repair(Repair::getBeforeUpgradeRepairSteps(), \OC::$server->get(\OCP\EventDispatcher\IEventDispatcher::class), \OC::$server->get(LoggerInterface::class)); @@ -399,7 +399,7 @@ class Updater extends BasicEmitter { * @return bool */ private function isCodeUpgrade(): bool { - $installedVersion = $this->config->getSystemValue('version', '0.0.0'); + $installedVersion = $this->config->getSystemValueString('version', '0.0.0'); $currentVersion = implode('.', Util::getVersion()); if (version_compare($currentVersion, $installedVersion, '>')) { return true; diff --git a/lib/private/Updater/VersionCheck.php b/lib/private/Updater/VersionCheck.php index 156d1c2e02f..a634ae4cc71 100644 --- a/lib/private/Updater/VersionCheck.php +++ b/lib/private/Updater/VersionCheck.php @@ -64,7 +64,7 @@ class VersionCheck { return json_decode($this->config->getAppValue('core', 'lastupdateResult'), true); } - $updaterUrl = $this->config->getSystemValue('updater.server.url', 'https://updates.nextcloud.com/updater_server/'); + $updaterUrl = $this->config->getSystemValueString('updater.server.url', 'https://updates.nextcloud.com/updater_server/'); $this->config->setAppValue('core', 'lastupdatedat', (string)time()); diff --git a/lib/private/User/Database.php b/lib/private/User/Database.php index 944202f244e..615c392395e 100644 --- a/lib/private/User/Database.php +++ b/lib/private/User/Database.php @@ -447,7 +447,7 @@ class Database extends ABackend implements */ public function getHome(string $uid) { if ($this->userExists($uid)) { - return \OC::$server->getConfig()->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data') . '/' . $uid; + return \OC::$server->getConfig()->getSystemValueString('datadirectory', \OC::$SERVERROOT . '/data') . '/' . $uid; } return false; diff --git a/lib/private/User/Session.php b/lib/private/User/Session.php index 3e45ebeab2b..078539e5489 100644 --- a/lib/private/User/Session.php +++ b/lib/private/User/Session.php @@ -491,8 +491,8 @@ class Session implements IUserSession, Emitter { return false; } - private function isTokenAuthEnforced() { - return $this->config->getSystemValue('token_auth_enforced', false); + private function isTokenAuthEnforced(): bool { + return $this->config->getSystemValueBool('token_auth_enforced', false); } protected function isTwoFactorEnforced($username) { @@ -958,7 +958,7 @@ class Session implements IUserSession, Emitter { $webRoot = '/'; } - $maxAge = $this->config->getSystemValue('remember_login_cookie_lifetime', 60 * 60 * 24 * 15); + $maxAge = $this->config->getSystemValueInt('remember_login_cookie_lifetime', 60 * 60 * 24 * 15); \OC\Http\CookieHelper::setCookie( 'nc_username', $username, diff --git a/lib/private/User/User.php b/lib/private/User/User.php index 2d80dbc7adf..c3d8af6f358 100644 --- a/lib/private/User/User.php +++ b/lib/private/User/User.php @@ -363,7 +363,7 @@ class User implements IUser { if (($this->backend instanceof IGetHomeBackend || $this->backend->implementsActions(Backend::GET_HOME)) && $home = $this->backend->getHome($this->uid)) { $this->home = $home; } elseif ($this->config) { - $this->home = $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data') . '/' . $this->uid; + $this->home = $this->config->getSystemValueString('datadirectory', \OC::$SERVERROOT . '/data') . '/' . $this->uid; } else { $this->home = \OC::$SERVERROOT . '/data/' . $this->uid; } @@ -416,7 +416,7 @@ class User implements IUser { * @return bool */ public function canChangeDisplayName() { - if ($this->config->getSystemValue('allow_user_to_change_display_name') === false) { + if (!$this->config->getSystemValueBool('allow_user_to_change_display_name')) { return false; } return $this->backend->implementsActions(Backend::SET_DISPLAYNAME); diff --git a/lib/private/legacy/OC_FileChunking.php b/lib/private/legacy/OC_FileChunking.php index e3782cabb4a..58bdd0af3d0 100644 --- a/lib/private/legacy/OC_FileChunking.php +++ b/lib/private/legacy/OC_FileChunking.php @@ -49,7 +49,7 @@ class OC_FileChunking { */ public function __construct($info) { $this->info = $info; - $this->ttl = \OC::$server->getConfig()->getSystemValue('cache_chunk_gc_ttl', 86400); + $this->ttl = \OC::$server->getConfig()->getSystemValueInt('cache_chunk_gc_ttl', 86400); } public function getPrefix() { diff --git a/lib/private/legacy/OC_Helper.php b/lib/private/legacy/OC_Helper.php index 8d708118b96..07d81933d00 100644 --- a/lib/private/legacy/OC_Helper.php +++ b/lib/private/legacy/OC_Helper.php @@ -634,6 +634,6 @@ class OC_Helper { * @return bool */ public static function isReadOnlyConfigEnabled() { - return \OC::$server->getConfig()->getSystemValue('config_is_read_only', false); + return \OC::$server->getConfig()->getSystemValueBool('config_is_read_only', false); } } diff --git a/lib/private/legacy/OC_Util.php b/lib/private/legacy/OC_Util.php index 7f06900feb0..f1f1f810658 100644 --- a/lib/private/legacy/OC_Util.php +++ b/lib/private/legacy/OC_Util.php @@ -185,7 +185,7 @@ class OC_Util { /** @var LoggerInterface $logger */ $logger = \OC::$server->get(LoggerInterface::class); - $plainSkeletonDirectory = \OC::$server->getConfig()->getSystemValue('skeletondirectory', \OC::$SERVERROOT . '/core/skeleton'); + $plainSkeletonDirectory = \OC::$server->getConfig()->getSystemValueString('skeletondirectory', \OC::$SERVERROOT . '/core/skeleton'); $userLang = \OC::$server->getL10NFactory()->findLanguage(); $skeletonDirectory = str_replace('{lang}', $userLang, $plainSkeletonDirectory); @@ -306,7 +306,7 @@ class OC_Util { */ public static function getChannel() { OC_Util::loadVersion(); - return \OC::$server->getConfig()->getSystemValue('updater.release.channel', self::$versionCache['OC_Channel']); + return \OC::$server->getConfig()->getSystemValueString('updater.release.channel', self::$versionCache['OC_Channel']); } /** @@ -783,7 +783,7 @@ class OC_Util { * @return array arrays with error messages and hints */ public static function checkDataDirectoryPermissions($dataDirectory) { - if (\OC::$server->getConfig()->getSystemValue('check_data_directory_permissions', true) === false) { + if (!\OC::$server->getConfig()->getSystemValueBool('check_data_directory_permissions', true)) { return []; } @@ -957,7 +957,7 @@ class OC_Util { $testContent = 'This is used for testing whether htaccess is properly enabled to disallow access from the outside. This file can be safely removed.'; // creating a test file - $testFile = $config->getSystemValue('datadirectory', OC::$SERVERROOT . '/data') . '/' . $fileName; + $testFile = $config->getSystemValueString('datadirectory', OC::$SERVERROOT . '/data') . '/' . $fileName; if (file_exists($testFile)) {// already running this test, possible recursive call return false; @@ -983,7 +983,7 @@ class OC_Util { * @throws \OCP\HintException If the test file can't get written. */ public function isHtaccessWorking(\OCP\IConfig $config) { - if (\OC::$CLI || !$config->getSystemValue('check_for_working_htaccess', true)) { + if (\OC::$CLI || !$config->getSystemValueBool('check_for_working_htaccess', true)) { return true; } @@ -993,7 +993,7 @@ class OC_Util { } $fileName = '/htaccesstest.txt'; - $testFile = $config->getSystemValue('datadirectory', OC::$SERVERROOT . '/data') . '/' . $fileName; + $testFile = $config->getSystemValueString('datadirectory', OC::$SERVERROOT . '/data') . '/' . $fileName; // accessing the file via http $url = \OC::$server->getURLGenerator()->getAbsoluteURL(OC::$WEBROOT . '/data' . $fileName);