diff --git a/lib/base.php b/lib/base.php index aebe2764be1a4..9c588bdaa76f0 100644 --- a/lib/base.php +++ b/lib/base.php @@ -569,7 +569,7 @@ private static function performSameSiteCookieProtection(\OCP\IConfig $config): v 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_PRECONDITION_FAILED); header('Content-Type: application/json'); echo json_encode(['error' => 'Strict Cookie has not been found in request']); @@ -674,7 +674,7 @@ public static function init(): void { \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']; @@ -735,7 +735,7 @@ public static function init(): void { 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'); } } @@ -805,7 +805,7 @@ public static function init(): void { */ 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 0eb089bbdc2a3..095b026cb4488 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 @@ protected function fetch($ETag, $content) { */ 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 @@ public function get($allowUnstable = false) { */ 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 @@ public function setChannel(string $channel) { } 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 01bf6748654cd..1cab740bebbad 100644 --- a/lib/private/App/Platform.php +++ b/lib/private/App/Platform.php @@ -56,7 +56,7 @@ public function getOcVersion(): string { } 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 1f32d6c5461fa..52abb909b6017 100644 --- a/lib/private/AppFramework/Http/Request.php +++ b/lib/private/AppFramework/Http/Request.php @@ -624,7 +624,7 @@ public function getRemoteAddress(): string { * @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 @@ private function isOverwriteCondition(string $type = ''): bool { * @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 @@ public function getHttpProtocol(): string { */ 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 @@ public function getPathInfo() { */ 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 @@ public function getServerHost(): string { * 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 04ed7ed846ee8..56ea042a66237 100644 --- a/lib/private/Authentication/Login/FinishRememberedLoginCommand.php +++ b/lib/private/Authentication/Login/FinishRememberedLoginCommand.php @@ -41,7 +41,7 @@ public function __construct(Session $userSession, IConfig $config) { } 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 b1fa509d8c004..f5fcd4dcef242 100644 --- a/lib/private/Authentication/Token/PublicKeyTokenProvider.php +++ b/lib/private/Authentication/Token/PublicKeyTokenProvider.php @@ -265,10 +265,10 @@ public function invalidateTokenById(string $uid, int $id) { 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); } @@ -366,7 +366,7 @@ public function rotate(IToken $token, string $oldTokenId, string $newTokenId): I } 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); } @@ -374,7 +374,7 @@ private function encrypt(string $plaintext, string $token): string { * @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) { @@ -404,7 +404,7 @@ private function decryptPassword(string $encryptedPassword, string $privateKey): } 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 a9038a0aa35e8..86ac70ab97094 100644 --- a/lib/private/Collaboration/Collaborators/LookupPlugin.php +++ b/lib/private/Collaboration/Collaborators/LookupPlugin.php @@ -63,7 +63,7 @@ public function __construct(IConfig $config, } 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 @@ public function search($search, $limit, $offset, ISearchResult $searchResult) { 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 07e9dbb317b27..0ed436fb0e6cc 100644 --- a/lib/private/Console/Application.php +++ b/lib/private/Console/Application.php @@ -112,7 +112,7 @@ public function loadCommands( 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 97d91e1c1003a..74e5a28535165 100644 --- a/lib/private/DB/Migrator.php +++ b/lib/private/DB/Migrator.php @@ -178,7 +178,7 @@ protected function convertStatementToScript($statement) { } 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 db9fc33f07f35..18deb97ec26f3 100644 --- a/lib/private/DB/OracleMigrator.php +++ b/lib/private/DB/OracleMigrator.php @@ -216,6 +216,6 @@ protected function convertStatementToScript($statement) { } 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 2781d3556e269..af385eb513613 100644 --- a/lib/private/DB/PgSqlTools.php +++ b/lib/private/DB/PgSqlTools.php @@ -53,7 +53,7 @@ public function resynchronizeDatabaseSequences(Connection $conn) { $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 b6376dc014669..e88c305eeeca9 100644 --- a/lib/private/Encryption/Keys/Storage.php +++ b/lib/private/Encryption/Keys/Storage.php @@ -237,7 +237,7 @@ private function getKeyWithUid(string $path, ?string $uid): string { 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 @@ private function getKey($path): array { $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 @@ private function getKey($path): array { 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 a553d6a55d18a..f751bd94b28ab 100644 --- a/lib/private/Encryption/Manager.php +++ b/lib/private/Encryption/Manager.php @@ -73,7 +73,7 @@ public function __construct(IConfig $config, LoggerInterface $logger, IL10N $l10 * @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 371f2588289cf..6ae0006e9559a 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 @@ public function __construct( $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 910b18b3e984f..d390037d0b854 100644 --- a/lib/private/Files/Cache/Scanner.php +++ b/lib/private/Files/Cache/Scanner.php @@ -92,7 +92,7 @@ public function __construct(\OC\Files\Storage\Storage $storage) { $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(); } diff --git a/lib/private/Files/Mount/CacheMountProvider.php b/lib/private/Files/Mount/CacheMountProvider.php index 90dfa0b05f309..903b93276c016 100644 --- a/lib/private/Files/Mount/CacheMountProvider.php +++ b/lib/private/Files/Mount/CacheMountProvider.php @@ -52,7 +52,7 @@ public function __construct(IConfig $config) { * @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 23f63dee2641e..abbcf4ea4331b 100644 --- a/lib/private/Files/Storage/Common.php +++ b/lib/private/Files/Storage/Common.php @@ -837,7 +837,7 @@ public function changeLock($path, $type, ILockingProvider $provider) { 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 0c4a81b7491bc..9388e2b20a840 100644 --- a/lib/private/Files/Storage/DAV.php +++ b/lib/private/Files/Storage/DAV.php @@ -145,7 +145,7 @@ protected function init() { $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 448346e562251..c5f518975598e 100644 --- a/lib/private/Files/Storage/Local.php +++ b/lib/private/Files/Storage/Local.php @@ -93,7 +93,7 @@ public function __construct($arguments) { $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 @@ public function getSourcePath($path) { $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 4603c14278f75..bf72e9e23e808 100644 --- a/lib/private/Files/Template/TemplateManager.php +++ b/lib/private/Files/Template/TemplateManager.php @@ -268,8 +268,8 @@ public function initializeTemplateDirectory(string $path = null, string $userId $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 a5449ade691eb..66abbfc15db29 100644 --- a/lib/private/GlobalScale/Config.php +++ b/lib/private/GlobalScale/Config.php @@ -44,8 +44,7 @@ public function __construct(IConfig $config) { * @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 @@ public function onlyInternalFederation() { 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 2e3703951320a..298749d52e161 100644 --- a/lib/private/Http/Client/Client.php +++ b/lib/private/Http/Client/Client.php @@ -122,7 +122,7 @@ private function getCertBundle(): string { // 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 @@ private function getCertBundle(): string { * */ 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 9587e0fd42a88..94e82223168cf 100644 --- a/lib/private/IntegrityCheck/Checker.php +++ b/lib/private/IntegrityCheck/Checker.php @@ -116,9 +116,9 @@ public function isCodeCheckEnforced(): bool { */ $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 120791f5b035c..a0b48158b9fe6 100644 --- a/lib/private/IntegrityCheck/Iterator/ExcludeFoldersByPathFilterIterator.php +++ b/lib/private/IntegrityCheck/Iterator/ExcludeFoldersByPathFilterIterator.php @@ -51,7 +51,7 @@ public function __construct(\RecursiveIterator $iterator, $root = '') { 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 593af02bd1c08..1082662933fad 100644 --- a/lib/private/L10N/Factory.php +++ b/lib/private/L10N/Factory.php @@ -195,7 +195,7 @@ public function findLanguage(?string $appId = null): string { * * @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 @@ public function findGenericLanguage(string $appId = null): string { } // 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 @@ public function findLocale($lang = null) { 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 @@ public function findAvailableLanguages($app = null): array { } // 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 @@ public function getUserLanguage(IUser $user = null): string { } } - return $this->config->getSystemValue('default_language', 'en'); + return $this->config->getSystemValueString('default_language', 'en'); } /** @@ -576,7 +576,7 @@ public function getL10nFilesForApp($app, $lang) { } // 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 b3549782d543a..8b3aaf1021058 100644 --- a/lib/private/L10N/LanguageIterator.php +++ b/lib/private/L10N/LanguageIterator.php @@ -93,10 +93,10 @@ public function current(): string { $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'); + $defaultLang = $this->config->getSystemValueString('default_language', 'en'); if (($truncated = $this->getTruncatedLanguage($defaultLang)) !== $defaultLang) { return $truncated; } diff --git a/lib/private/Log/Rotate.php b/lib/private/Log/Rotate.php index 20bc3327f92aa..dfb588837f33b 100644 --- a/lib/private/Log/Rotate.php +++ b/lib/private/Log/Rotate.php @@ -39,7 +39,7 @@ public function run($dummy) { $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 05ef0bf513962..5d838b2cdf1f0 100644 --- a/lib/private/Mail/Mailer.php +++ b/lib/private/Mail/Mailer.php @@ -57,7 +57,6 @@ 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 @@ public function __construct(IConfig $config, * @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 @@ public function createAttachmentFromPath(string $path, $contentType = null): IAt * @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 @@ public function createEMailTemplate(string $emailId, array $data = []): IEMailTe * @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 @@ public function send(IMessage $message): array { 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 @@ protected function getInstance(): MailerInterface { $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 @@ protected function getSmtpInstance(): EsmtpTransport { $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 @@ protected function getSmtpInstance(): EsmtpTransport { /** @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 @@ protected function getSmtpInstance(): EsmtpTransport { * @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 @@ protected function getSendMailInstance(): SendmailTransport { 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 2050244d3846f..56f55e80331c0 100644 --- a/lib/private/NavigationManager.php +++ b/lib/private/NavigationManager.php @@ -189,7 +189,7 @@ private function init() { $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 ca46383e58b01..962e5663b3902 100644 --- a/lib/private/Preview/Imaginary.php +++ b/lib/private/Preview/Imaginary.php @@ -61,7 +61,7 @@ public static function supportedMimeTypes(): string { } 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 @@ public function getCroppedThumbnail(File $file, int $maxX, int $maxY, bool $crop default: $mimeType = 'jpeg'; } - + $operations = []; if ($convert) { diff --git a/lib/private/PreviewManager.php b/lib/private/PreviewManager.php index dd6b6ba8ee112..814235f421287 100644 --- a/lib/private/PreviewManager.php +++ b/lib/private/PreviewManager.php @@ -113,7 +113,7 @@ public function __construct( * @return void */ public function registerProvider($mimeTypeRegex, \Closure $callable): void { - if (!$this->config->getSystemValue('enable_previews', true)) { + if (!$this->config->getSystemValueBool('enable_previews', true)) { return; } @@ -128,7 +128,7 @@ public function registerProvider($mimeTypeRegex, \Closure $callable): void { * Get all providers */ public function getProviders(): array { - if (!$this->config->getSystemValue('enable_previews', true)) { + if (!$this->config->getSystemValueBool('enable_previews', true)) { return []; } @@ -219,7 +219,7 @@ public function generatePreviews(File $file, array $specifications, $mimeType = * @return boolean */ public function isMimeSupported($mimeType = '*') { - if (!$this->config->getSystemValue('enable_previews', true)) { + if (!$this->config->getSystemValueBool('enable_previews', true)) { return false; } @@ -244,7 +244,7 @@ public function isMimeSupported($mimeType = '*') { * Check if a preview can be generated for a file */ public function isAvailable(\OCP\Files\FileInfo $file): bool { - if (!$this->config->getSystemValue('enable_previews', true)) { + if (!$this->config->getSystemValueBool('enable_previews', true)) { return false; } diff --git a/lib/private/Repair/ClearGeneratedAvatarCache.php b/lib/private/Repair/ClearGeneratedAvatarCache.php index db86d92cd87d7..844bf6cf346f9 100644 --- a/lib/private/Repair/ClearGeneratedAvatarCache.php +++ b/lib/private/Repair/ClearGeneratedAvatarCache.php @@ -49,7 +49,7 @@ public function getName(): string { * 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 25e85f00af84e..6f7dde6886588 100644 --- a/lib/private/Repair/Collation.php +++ b/lib/private/Repair/Collation.php @@ -74,7 +74,7 @@ public function run(IOutput $output) { 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 @@ public function run(IOutput $output) { * @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 905fc9451f54f..fc3b9dce1f386 100644 --- a/lib/private/Repair/MoveUpdaterStepFile.php +++ b/lib/private/Repair/MoveUpdaterStepFile.php @@ -43,9 +43,9 @@ public function getName() { 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 b12604cd132d9..394e47dfcda08 100644 --- a/lib/private/Repair/NC16/CleanupCardDAVPhotoCache.php +++ b/lib/private/Repair/NC16/CleanupCardDAVPhotoCache.php @@ -96,7 +96,7 @@ private function repair(IOutput $output): void { 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 51a63406d2296..076e27a6ceb98 100644 --- a/lib/private/Repair/NC16/ClearCollectionsAccessCache.php +++ b/lib/private/Repair/NC16/ClearCollectionsAccessCache.php @@ -48,7 +48,7 @@ public function getName(): string { } 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 3635c86e1b9a3..d5ae1d7ab63a9 100644 --- a/lib/private/Repair/NC18/ResetGeneratedAvatarFlag.php +++ b/lib/private/Repair/NC18/ResetGeneratedAvatarFlag.php @@ -47,7 +47,7 @@ public function getName(): string { } 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 6e31423915f24..a7d008e87beda 100644 --- a/lib/private/Repair/NC20/EncryptionLegacyCipher.php +++ b/lib/private/Repair/NC20/EncryptionLegacyCipher.php @@ -48,7 +48,7 @@ public function getName(): string { } 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 6e209314462d8..239a62c271806 100644 --- a/lib/private/Repair/NC20/EncryptionMigration.php +++ b/lib/private/Repair/NC20/EncryptionMigration.php @@ -48,7 +48,7 @@ public function getName(): string { } 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 e9b26947db69d..ee413ce12caeb 100644 --- a/lib/private/Repair/NC21/AddCheckForUserCertificatesJob.php +++ b/lib/private/Repair/NC21/AddCheckForUserCertificatesJob.php @@ -44,7 +44,7 @@ public function getName() { } 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 46029357dbe28..93475d88a2d8a 100644 --- a/lib/private/Repair/NC22/LookupServerSendCheck.php +++ b/lib/private/Repair/NC22/LookupServerSendCheck.php @@ -46,7 +46,7 @@ public function getName(): string { } 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 1194fe3f6ab2e..d3a438b89c156 100644 --- a/lib/private/Repair/NC25/AddMissingSecretJob.php +++ b/lib/private/Repair/NC25/AddMissingSecretJob.php @@ -42,8 +42,8 @@ public function getName(): string { } 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 @@ public function run(IOutput $output): void { } } - $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 fa3dd92464812..44ba9b7643b11 100644 --- a/lib/private/Repair/Owncloud/MoveAvatars.php +++ b/lib/private/Repair/Owncloud/MoveAvatars.php @@ -59,7 +59,7 @@ public function run(IOutput $output) { $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 13677d80de0ad..94fd15542936e 100644 --- a/lib/private/Repair/Owncloud/SaveAccountsTableData.php +++ b/lib/private/Repair/Owncloud/SaveAccountsTableData.php @@ -79,7 +79,7 @@ public function run(IOutput $output) { } // 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 @@ public function run(IOutput $output) { */ 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 cb4525b6c1dd3..e08a0b55a9a84 100644 --- a/lib/private/Repair/Owncloud/UpdateLanguageCodes.php +++ b/lib/private/Repair/Owncloud/UpdateLanguageCodes.php @@ -56,7 +56,7 @@ public function getName() { * {@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 71eead1053b17..b45a1d83a56c0 100644 --- a/lib/private/Repair/RemoveLinkShares.php +++ b/lib/private/Repair/RemoveLinkShares.php @@ -71,7 +71,7 @@ public function getName(): string { } 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 9c0bce66ae870..467adc2b0d9bb 100644 --- a/lib/private/Repair/RepairDavShares.php +++ b/lib/private/Repair/RepairDavShares.php @@ -125,7 +125,7 @@ protected function repairUnencodedGroupShares() { * @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 c34d5d9e00579..9255034f6fe11 100644 --- a/lib/private/Repair/RepairInvalidShares.php +++ b/lib/private/Repair/RepairInvalidShares.php @@ -110,7 +110,7 @@ private function removeSharesNonExistingParent(IOutput $out) { } 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 5f3531ea79cf7..ee5a84ad65c13 100644 --- a/lib/private/Repair/RepairMimeTypes.php +++ b/lib/private/Repair/RepairMimeTypes.php @@ -234,7 +234,7 @@ private function introduceOnlyofficeFormType() { * 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 5de4f35f24ea7..60cf3086f2db9 100644 --- a/lib/private/Security/Bruteforce/Capabilities.php +++ b/lib/private/Security/Bruteforce/Capabilities.php @@ -51,7 +51,7 @@ public function __construct(IRequest $request, } 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 299cab93eb316..d5fd0984baab6 100644 --- a/lib/private/Security/Bruteforce/Throttler.php +++ b/lib/private/Security/Bruteforce/Throttler.php @@ -112,7 +112,7 @@ public function registerAttempt(string $action, 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 @@ public function registerAttempt(string $action, * @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 be884654bd0bd..ee68f602bd170 100644 --- a/lib/private/Security/CertificateManager.php +++ b/lib/private/Security/CertificateManager.php @@ -67,7 +67,7 @@ public function __construct(View $view, * @return \OCP\ICertificate[] */ public function listCertificates(): array { - if (!$this->config->getSystemValue('installed', false)) { + if (!$this->config->getSystemValueBool('installed', false)) { return []; } @@ -93,7 +93,7 @@ public function listCertificates(): array { } 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 aeeafcc271c52..2a7905376ef0e 100644 --- a/lib/private/Security/Crypto.php +++ b/lib/private/Security/Crypto.php @@ -70,7 +70,7 @@ public function __construct(IConfig $config) { */ 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 @@ public function calculateHMAC(string $message, string $password = ''): string { */ 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 4731ba96bd341..85f6926392593 100644 --- a/lib/private/Security/Hasher.php +++ b/lib/private/Security/Hasher.php @@ -209,7 +209,7 @@ private function getPrefferedAlgorithm() { } // 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 2d3f902b62228..52c3f62b81341 100644 --- a/lib/private/Security/VerificationToken/VerificationToken.php +++ b/lib/private/Security/VerificationToken/VerificationToken.php @@ -82,7 +82,7 @@ public function check(string $token, ?IUser $user, string $subject, string $pass } 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 @@ public function create(IUser $user, string $subject, string $passwordPrefix = '' 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 4cf278c82a92e..bb4e217efa3bb 100644 --- a/lib/private/Server.php +++ b/lib/private/Server.php @@ -728,7 +728,7 @@ public function __construct($webRoot, \OC\Config $config) { /** @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 { @@ -990,7 +990,7 @@ public function __construct($webRoot, \OC\Config $config) { /** @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)) { @@ -1109,8 +1109,8 @@ public function __construct($webRoot, \OC\Config $config) { $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'); @@ -1210,7 +1210,7 @@ public function __construct($webRoot, \OC\Config $config) { $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 e8371ba85425b..7567aaf14b1da 100644 --- a/lib/private/Setup.php +++ b/lib/private/Setup.php @@ -410,7 +410,7 @@ public function install($options) { // 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 @@ public static function protectDataDirectory() { $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 26e5549ccffdc..732bd5bb97d39 100644 --- a/lib/private/Share20/Manager.php +++ b/lib/private/Share20/Manager.php @@ -1179,7 +1179,7 @@ private function updateSharePasswordIfNeeded(IShare $share, IShare $originalShar * 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 7aafa539a0bc8..eba76ca103ead 100644 --- a/lib/private/Support/Subscription/Registry.php +++ b/lib/private/Support/Subscription/Registry.php @@ -176,7 +176,7 @@ public function delegateIsHardUserLimitReached(?IManager $notificationManager = } $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 123fd6debb56d..52c60e58991da 100644 --- a/lib/private/TemplateLayout.php +++ b/lib/private/TemplateLayout.php @@ -221,7 +221,7 @@ public function __construct($renderAs, $appId = '') { // 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 @@ public function __construct($renderAs, $appId = '') { * @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 a5a3609703b09..2410b8a914764 100644 --- a/lib/private/URLGenerator.php +++ b/lib/private/URLGenerator.php @@ -141,7 +141,7 @@ public function linkToOCSRouteAbsolute(string $routeName, array $arguments = []) * 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 @@ public function imagePath(string $appName, string $file): string { // 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 @@ public function getAbsoluteURL(string $url): string { $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 @@ public function linkToDefaultPageUrl(): string { $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 2ca4c662a85e2..5628516632222 100644 --- a/lib/private/Updater.php +++ b/lib/private/Updater.php @@ -129,7 +129,7 @@ public function upgrade(): bool { } } - $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 @@ public function isUpgradePossible(string $oldVersion, string $newVersion, array 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 @@ private function doUpgrade(string $currentVersion, string $installedVersion): vo // 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 @@ private function checkAppsRequirements(): void { * @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 156d1c2e02f82..a634ae4cc710d 100644 --- a/lib/private/Updater/VersionCheck.php +++ b/lib/private/Updater/VersionCheck.php @@ -64,7 +64,7 @@ public function check() { 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 944202f244e6f..615c392395e88 100644 --- a/lib/private/User/Database.php +++ b/lib/private/User/Database.php @@ -447,7 +447,7 @@ public function userExists($uid) { */ 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 3e45ebeab2b83..078539e548932 100644 --- a/lib/private/User/Session.php +++ b/lib/private/User/Session.php @@ -491,8 +491,8 @@ protected function supportsCookies(IRequest $request) { 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 @@ public function setMagicInCookie($username, $token) { $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 2d80dbc7adf27..c3d8af6f358df 100644 --- a/lib/private/User/User.php +++ b/lib/private/User/User.php @@ -363,7 +363,7 @@ public function getHome() { 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 @@ public function canChangePassword() { * @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 e3782cabb4a72..58bdd0af3d0f8 100644 --- a/lib/private/legacy/OC_FileChunking.php +++ b/lib/private/legacy/OC_FileChunking.php @@ -49,7 +49,7 @@ public static function decodeName($name) { */ 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 8d708118b964b..07d81933d0009 100644 --- a/lib/private/legacy/OC_Helper.php +++ b/lib/private/legacy/OC_Helper.php @@ -634,6 +634,6 @@ public static function clearStorageInfo(string $absolutePath): void { * @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 7f06900feb093..f1f1f810658da 100644 --- a/lib/private/legacy/OC_Util.php +++ b/lib/private/legacy/OC_Util.php @@ -185,7 +185,7 @@ public static function copySkeleton($userId, \OCP\Files\Folder $userDirectory) { /** @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 @@ public static function getEditionString() { */ 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 @@ public static function checkDatabaseVersion() { * @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 @@ public function createHtaccessTestFile(\OCP\IConfig $config) { $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 @@ public function createHtaccessTestFile(\OCP\IConfig $config) { * @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 @@ public function isHtaccessWorking(\OCP\IConfig $config) { } $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); diff --git a/tests/Test/Repair/Owncloud/UpdateLanguageCodesTest.php b/tests/Test/Repair/Owncloud/UpdateLanguageCodesTest.php index b5d339eef2f88..6d34babe76af6 100644 --- a/tests/Test/Repair/Owncloud/UpdateLanguageCodesTest.php +++ b/tests/Test/Repair/Owncloud/UpdateLanguageCodesTest.php @@ -109,7 +109,7 @@ public function testRun() { ); $this->config->expects($this->once()) - ->method('getSystemValue') + ->method('getSystemValueString') ->with('version', '0.0.0') ->willReturn('12.0.0.13'); @@ -155,7 +155,7 @@ public function testSecondRun() { ->method('info'); $this->config->expects($this->once()) - ->method('getSystemValue') + ->method('getSystemValueString') ->with('version', '0.0.0') ->willReturn('12.0.0.14'); diff --git a/tests/lib/App/AppStore/Fetcher/AppFetcherTest.php b/tests/lib/App/AppStore/Fetcher/AppFetcherTest.php index a2d56838b07c1..39b0a699092b5 100644 --- a/tests/lib/App/AppStore/Fetcher/AppFetcherTest.php +++ b/tests/lib/App/AppStore/Fetcher/AppFetcherTest.php @@ -1872,7 +1872,7 @@ protected function setUp(): void { } public function testGetWithFilter() { - $this->config->method('getSystemValue') + $this->config->method('getSystemValueString') ->willReturnCallback(function ($key, $default) { if ($key === 'version') { return '11.0.0.2'; @@ -1884,8 +1884,7 @@ public function testGetWithFilter() { }); $this->config ->method('getSystemValueBool') - ->with('appstoreenabled', true) - ->willReturn(true); + ->willReturnArgument(1); $file = $this->createMock(ISimpleFile::class); $folder = $this->createMock(ISimpleFolder::class); @@ -1957,7 +1956,7 @@ public function testGetWithFilter() { public function testAppstoreDisabled() { $this->config - ->method('getSystemValue') + ->method('getSystemValueString') ->willReturnCallback(function ($var, $default) { if ($var === 'version') { return '11.0.0.2'; @@ -1966,8 +1965,14 @@ public function testAppstoreDisabled() { }); $this->config ->method('getSystemValueBool') - ->with('appstoreenabled', true) - ->willReturn(false); + ->willReturnCallback(function ($var, $default) { + if ($var === 'has_internet_connection') { + return true; + } elseif ($var === 'appstoreenabled') { + return false; + } + return $default; + }); $this->appData ->expects($this->never()) ->method('getFolder'); @@ -1978,7 +1983,7 @@ public function testAppstoreDisabled() { public function testNoInternet() { $this->config - ->method('getSystemValue') + ->method('getSystemValueString') ->willReturnCallback(function ($var, $default) { if ($var === 'has_internet_connection') { return false; @@ -1989,8 +1994,14 @@ public function testNoInternet() { }); $this->config ->method('getSystemValueBool') - ->with('appstoreenabled', true) - ->willReturn(true); + ->willReturnCallback(function ($var, $default) { + if ($var === 'has_internet_connection') { + return false; + } elseif ($var === 'appstoreenabled') { + return true; + } + return $default; + }); $this->appData ->expects($this->never()) ->method('getFolder'); @@ -1999,7 +2010,7 @@ public function testNoInternet() { } public function testSetVersion() { - $this->config->method('getSystemValue') + $this->config->method('getSystemValueString') ->willReturnCallback(function ($key, $default) { if ($key === 'version') { return '10.0.7.2'; @@ -2011,8 +2022,7 @@ public function testSetVersion() { }); $this->config ->method('getSystemValueBool') - ->with('appstoreenabled', true) - ->willReturn(true); + ->willReturnArgument(1); $file = $this->createMock(ISimpleFile::class); $folder = $this->createMock(ISimpleFolder::class); @@ -2084,13 +2094,19 @@ public function testSetVersion() { } public function testGetAppsAllowlist() { - $this->config->method('getSystemValue') + $this->config->method('getSystemValueString') ->willReturnCallback(function ($key, $default) { if ($key === 'version') { return '11.0.0.2'; } elseif ($key === 'appstoreurl' && $default === 'https://apps.nextcloud.com/api/v1') { return 'https://custom.appsstore.endpoint/api/v1'; - } elseif ($key === 'appsallowlist') { + } else { + return $default; + } + }); + $this->config->method('getSystemValue') + ->willReturnCallback(function ($key, $default) { + if ($key === 'appsallowlist') { return ['contacts']; } else { return $default; @@ -2098,8 +2114,7 @@ public function testGetAppsAllowlist() { }); $this->config ->method('getSystemValueBool') - ->with('appstoreenabled', true) - ->willReturn(true); + ->willReturnArgument(1); $file = $this->createMock(ISimpleFile::class); $folder = $this->createMock(ISimpleFolder::class); diff --git a/tests/lib/App/AppStore/Fetcher/CategoryFetcherTest.php b/tests/lib/App/AppStore/Fetcher/CategoryFetcherTest.php index b83e405db610c..874a58fc6bab9 100644 --- a/tests/lib/App/AppStore/Fetcher/CategoryFetcherTest.php +++ b/tests/lib/App/AppStore/Fetcher/CategoryFetcherTest.php @@ -41,7 +41,7 @@ protected function setUp(): void { public function testAppstoreDisabled() { $this->config - ->method('getSystemValue') + ->method('getSystemValueBool') ->willReturnCallback(function ($var, $default) { if ($var === 'appstoreenabled') { return false; @@ -57,7 +57,7 @@ public function testAppstoreDisabled() { public function testNoInternet() { $this->config - ->method('getSystemValue') + ->method('getSystemValueBool') ->willReturnCallback(function ($var, $default) { if ($var === 'has_internet_connection') { return false; diff --git a/tests/lib/App/AppStore/Fetcher/FetcherBase.php b/tests/lib/App/AppStore/Fetcher/FetcherBase.php index 42ad02ce6d820..dbc3f2a687cd3 100644 --- a/tests/lib/App/AppStore/Fetcher/FetcherBase.php +++ b/tests/lib/App/AppStore/Fetcher/FetcherBase.php @@ -76,20 +76,12 @@ protected function setUp(): void { public function testGetWithAlreadyExistingFileAndUpToDateTimestampAndVersion() { $this->config - ->expects($this->once()) - ->method('getSystemValueBool') - ->with('appstoreenabled', true) - ->willReturn(true); - $this->config - ->expects($this->exactly(2)) - ->method('getSystemValue') - ->withConsecutive( - ['has_internet_connection', true], - [$this->equalTo('version'), $this->anything()], - )->willReturnOnConsecutiveCalls( - true, - '11.0.0.2', - ); + ->expects($this->exactly(1)) + ->method('getSystemValueString') + ->with($this->equalTo('version'), $this->anything()) + ->willReturn('11.0.0.2'); + $this->config->method('getSystemValueBool') + ->willReturnArgument(1); $folder = $this->createMock(ISimpleFolder::class); $file = $this->createMock(ISimpleFile::class); @@ -122,21 +114,17 @@ public function testGetWithAlreadyExistingFileAndUpToDateTimestampAndVersion() { public function testGetWithNotExistingFileAndUpToDateTimestampAndVersion() { $this->config - ->method('getSystemValue') + ->method('getSystemValueString') ->willReturnCallback(function ($var, $default) { - if ($var === 'has_internet_connection') { - return true; - } elseif ($var === 'appstoreurl') { + if ($var === 'appstoreurl') { return 'https://apps.nextcloud.com/api/v1'; } elseif ($var === 'version') { return '11.0.0.2'; } return $default; }); - $this->config - ->method('getSystemValueBool') - ->with('appstoreenabled', $this->anything()) - ->willReturn(true); + $this->config->method('getSystemValueBool') + ->willReturnArgument(1); $folder = $this->createMock(ISimpleFolder::class); $file = $this->createMock(ISimpleFile::class); @@ -200,7 +188,7 @@ public function testGetWithNotExistingFileAndUpToDateTimestampAndVersion() { } public function testGetWithAlreadyExistingFileAndOutdatedTimestamp() { - $this->config->method('getSystemValue') + $this->config->method('getSystemValueString') ->willReturnCallback(function ($key, $default) { if ($key === 'version') { return '11.0.0.2'; @@ -208,10 +196,8 @@ public function testGetWithAlreadyExistingFileAndOutdatedTimestamp() { return $default; } }); - $this->config - ->method('getSystemValueBool') - ->with('appstoreenabled', true) - ->willReturn(true); + $this->config->method('getSystemValueBool') + ->willReturnArgument(1); $folder = $this->createMock(ISimpleFolder::class); $file = $this->createMock(ISimpleFile::class); @@ -277,21 +263,17 @@ public function testGetWithAlreadyExistingFileAndOutdatedTimestamp() { public function testGetWithAlreadyExistingFileAndNoVersion() { $this->config - ->method('getSystemValue') + ->method('getSystemValueString') ->willReturnCallback(function ($var, $default) { - if ($var === 'has_internet_connection') { - return true; - } elseif ($var === 'appstoreurl') { + if ($var === 'appstoreurl') { return 'https://apps.nextcloud.com/api/v1'; } elseif ($var === 'version') { return '11.0.0.2'; } return $default; }); - $this->config - ->method('getSystemValueBool') - ->with('appstoreenabled', true) - ->willReturn(true); + $this->config->method('getSystemValueBool') + ->willReturnArgument(1); $folder = $this->createMock(ISimpleFolder::class); $file = $this->createMock(ISimpleFile::class); @@ -354,21 +336,17 @@ public function testGetWithAlreadyExistingFileAndNoVersion() { public function testGetWithAlreadyExistingFileAndOutdatedVersion() { $this->config - ->method('getSystemValue') + ->method('getSystemValueString') ->willReturnCallback(function ($var, $default) { - if ($var === 'has_internet_connection') { - return true; - } elseif ($var === 'appstoreurl') { + if ($var === 'appstoreurl') { return 'https://apps.nextcloud.com/api/v1'; } elseif ($var === 'version') { return '11.0.0.2'; } return $default; }); - $this->config - ->method('getSystemValueBool') - ->with('appstoreenabled', true) - ->willReturn(true); + $this->config->method('getSystemValueBool') + ->willReturnArgument(1); $folder = $this->createMock(ISimpleFolder::class); $file = $this->createMock(ISimpleFile::class); @@ -429,14 +407,10 @@ public function testGetWithAlreadyExistingFileAndOutdatedVersion() { } public function testGetWithExceptionInClient() { - $this->config->method('getSystemValue') - ->willReturnCallback(function ($key, $default) { - return $default; - }); - $this->config - ->method('getSystemValueBool') - ->with('appstoreenabled', true) - ->willReturn(true); + $this->config->method('getSystemValueString') + ->willReturnArgument(1); + $this->config->method('getSystemValueBool') + ->willReturnArgument(1); $folder = $this->createMock(ISimpleFolder::class); $file = $this->createMock(ISimpleFile::class); @@ -469,7 +443,7 @@ public function testGetWithExceptionInClient() { } public function testGetMatchingETag() { - $this->config->method('getSystemValue') + $this->config->method('getSystemValueString') ->willReturnCallback(function ($key, $default) { if ($key === 'version') { return '11.0.0.2'; @@ -477,10 +451,8 @@ public function testGetMatchingETag() { return $default; } }); - $this->config - ->method('getSystemValueBool') - ->with('appstoreenabled', true) - ->willReturn(true); + $this->config->method('getSystemValueBool') + ->willReturnArgument(1); $folder = $this->createMock(ISimpleFolder::class); $file = $this->createMock(ISimpleFile::class); @@ -550,7 +522,7 @@ public function testGetMatchingETag() { } public function testGetNoMatchingETag() { - $this->config->method('getSystemValue') + $this->config->method('getSystemValueString') ->willReturnCallback(function ($key, $default) { if ($key === 'version') { return '11.0.0.2'; @@ -558,10 +530,8 @@ public function testGetNoMatchingETag() { return $default; } }); - $this->config - ->method('getSystemValueBool') - ->with('appstoreenabled', true) - ->willReturn(true); + $this->config->method('getSystemValueBool') + ->willReturnArgument(1); $folder = $this->createMock(ISimpleFolder::class); $file = $this->createMock(ISimpleFile::class); @@ -637,7 +607,7 @@ public function testGetNoMatchingETag() { public function testFetchAfterUpgradeNoETag() { - $this->config->method('getSystemValue') + $this->config->method('getSystemValueString') ->willReturnCallback(function ($key, $default) { if ($key === 'version') { return '11.0.0.3'; @@ -645,10 +615,8 @@ public function testFetchAfterUpgradeNoETag() { return $default; } }); - $this->config - ->method('getSystemValueBool') - ->with('appstoreenabled', true) - ->willReturn(true); + $this->config->method('getSystemValueBool') + ->willReturnArgument(1); $folder = $this->createMock(ISimpleFolder::class); $file = $this->createMock(ISimpleFile::class); diff --git a/tests/lib/AppFramework/Http/RequestTest.php b/tests/lib/AppFramework/Http/RequestTest.php index 78e656f5fc3a9..839c7ad433810 100644 --- a/tests/lib/AppFramework/Http/RequestTest.php +++ b/tests/lib/AppFramework/Http/RequestTest.php @@ -938,7 +938,7 @@ public function testGetHttpProtocol($input, $expected) { public function testGetServerProtocolWithOverride() { $this->config ->expects($this->exactly(3)) - ->method('getSystemValue') + ->method('getSystemValueString') ->willReturnMap([ ['overwriteprotocol', '', 'customProtocol'], ['overwritecondaddr', '', ''], @@ -1358,7 +1358,7 @@ public function testInsecureServerHostHttpFromForwardedHeaderStacked() { public function testGetServerHostWithOverwriteHost() { $this->config - ->method('getSystemValue') + ->method('getSystemValueString') ->willReturnCallback(function ($key, $default) { if ($key === 'overwritecondaddr') { return ''; @@ -1513,7 +1513,7 @@ public function testGetServerHostTrustedDomain($expected, $trustedDomain) { public function testGetOverwriteHostDefaultNull() { $this->config ->expects($this->once()) - ->method('getSystemValue') + ->method('getSystemValueString') ->with('overwritehost') ->willReturn(''); $request = new Request( @@ -1530,7 +1530,7 @@ public function testGetOverwriteHostDefaultNull() { public function testGetOverwriteHostWithOverwrite() { $this->config ->expects($this->exactly(3)) - ->method('getSystemValue') + ->method('getSystemValueString') ->willReturnMap([ ['overwritehost', '', 'www.owncloud.org'], ['overwritecondaddr', '', ''], @@ -1717,7 +1717,7 @@ public function pathInfoProvider() { public function testGetRequestUriWithoutOverwrite() { $this->config ->expects($this->once()) - ->method('getSystemValue') + ->method('getSystemValueString') ->with('overwritewebroot') ->willReturn(''); @@ -1749,7 +1749,7 @@ public function providesGetRequestUriWithOverwriteData() { public function testGetRequestUriWithOverwrite($expectedUri, $overwriteWebRoot, $overwriteCondAddr) { $this->config ->expects($this->exactly(2)) - ->method('getSystemValue') + ->method('getSystemValueString') ->willReturnMap([ ['overwritewebroot', '', $overwriteWebRoot], ['overwritecondaddr', '', $overwriteCondAddr], diff --git a/tests/lib/Authentication/Login/FinishRememberedLoginCommandTest.php b/tests/lib/Authentication/Login/FinishRememberedLoginCommandTest.php index d6f18ad9effb4..890dd63892a89 100644 --- a/tests/lib/Authentication/Login/FinishRememberedLoginCommandTest.php +++ b/tests/lib/Authentication/Login/FinishRememberedLoginCommandTest.php @@ -62,7 +62,7 @@ public function testProcessNotRememberedLogin() { public function testProcess() { $data = $this->getLoggedInLoginData(); $this->config->expects($this->once()) - ->method('getSystemValue') + ->method('getSystemValueBool') ->with('auto_logout', false) ->willReturn(false); $this->userSession->expects($this->once()) @@ -77,7 +77,7 @@ public function testProcess() { public function testProcessNotRemeberedLoginWithAutologout() { $data = $this->getLoggedInLoginData(); $this->config->expects($this->once()) - ->method('getSystemValue') + ->method('getSystemValueBool') ->with('auto_logout', false) ->willReturn(true); $this->userSession->expects($this->never()) diff --git a/tests/lib/Authentication/Token/PublicKeyTokenProviderTest.php b/tests/lib/Authentication/Token/PublicKeyTokenProviderTest.php index d19f98eeda96a..a614780a9080e 100644 --- a/tests/lib/Authentication/Token/PublicKeyTokenProviderTest.php +++ b/tests/lib/Authentication/Token/PublicKeyTokenProviderTest.php @@ -67,13 +67,20 @@ protected function setUp(): void { $this->hasher = \OC::$server->getHasher(); $this->crypto = \OC::$server->getCrypto(); $this->config = $this->createMock(IConfig::class); - $this->config->method('getSystemValue') + $this->config->method('getSystemValueInt') ->willReturnMap([ ['session_lifetime', 60 * 60 * 24, 150], ['remember_login_cookie_lifetime', 60 * 60 * 24 * 15, 300], - ['secret', '', '1f4h9s'], + ['token_auth_activity_update', 60, 60], + ]); + $this->config->method('getSystemValue') + ->willReturnMap([ ['openssl', [], []], ]); + $this->config->method('getSystemValueString') + ->willReturnMap([ + ['secret', '', '1f4h9s'], + ]); $this->db = $this->createMock(IDBConnection::class); $this->logger = $this->createMock(LoggerInterface::class); $this->timeFactory = $this->createMock(ITimeFactory::class); @@ -336,7 +343,7 @@ public function testInvalidateOldTokens() { $defaultSessionLifetime = 60 * 60 * 24; $defaultRememberMeLifetime = 60 * 60 * 24 * 15; $this->config->expects($this->exactly(2)) - ->method('getSystemValue') + ->method('getSystemValueInt') ->willReturnMap([ ['session_lifetime', $defaultSessionLifetime, 150], ['remember_login_cookie_lifetime', $defaultRememberMeLifetime, 300], diff --git a/tests/lib/Collaboration/Collaborators/LookupPluginTest.php b/tests/lib/Collaboration/Collaborators/LookupPluginTest.php index 462497c637bf0..3eb28a861a585 100644 --- a/tests/lib/Collaboration/Collaborators/LookupPluginTest.php +++ b/tests/lib/Collaboration/Collaborators/LookupPluginTest.php @@ -92,19 +92,19 @@ public function testSearchNoLookupServerURI() { ->with('files_sharing', 'lookupServerEnabled', 'yes') ->willReturn('yes'); $this->config->expects($this->exactly(2)) - ->method('getSystemValue') + ->method('getSystemValueBool') ->withConsecutive( ['gs.enabled', false], - ['lookup_server', 'https://lookup.nextcloud.com'], + ['has_internet_connection', true], )->willReturnOnConsecutiveCalls( false, - '', + true, ); $this->config->expects($this->once()) - ->method('getSystemValueBool') - ->with('has_internet_connection', true) - ->willReturn(true); + ->method('getSystemValueString') + ->with('lookup_server', 'https://lookup.nextcloud.com') + ->willReturn(''); $this->clientService->expects($this->never()) ->method('newClient'); @@ -120,15 +120,15 @@ public function testSearchNoInternet() { ->method('getAppValue') ->with('files_sharing', 'lookupServerEnabled', 'yes') ->willReturn('yes'); - $this->config->expects($this->once()) - ->method('getSystemValue') - ->with('gs.enabled', false) - ->willReturn(false); - - $this->config->expects($this->once()) + $this->config->expects($this->exactly(2)) ->method('getSystemValueBool') - ->with('has_internet_connection', true) - ->willReturn(false); + ->withConsecutive( + ['gs.enabled', false], + ['has_internet_connection', true], + )->willReturnOnConsecutiveCalls( + false, + false, + ); $this->clientService->expects($this->never()) ->method('newClient'); @@ -157,19 +157,19 @@ public function testSearch(array $searchParams) { ->with('files_sharing', 'lookupServerEnabled', 'yes') ->willReturn('yes'); $this->config->expects($this->exactly(2)) - ->method('getSystemValue') + ->method('getSystemValueBool') ->withConsecutive( ['gs.enabled', false], - ['lookup_server', 'https://lookup.nextcloud.com'], + ['has_internet_connection', true], )->willReturnOnConsecutiveCalls( false, - $searchParams['server'], + true, ); $this->config->expects($this->once()) - ->method('getSystemValueBool') - ->with('has_internet_connection', true) - ->willReturn(true); + ->method('getSystemValueString') + ->with('lookup_server', 'https://lookup.nextcloud.com') + ->willReturn($searchParams['server']); $response = $this->createMock(IResponse::class); $response->expects($this->once()) @@ -221,19 +221,19 @@ public function testSearchEnableDisableLookupServer(array $searchParams, $GSEnab ->method('addResultSet') ->with($type, $searchParams['expectedResult'], []); - $this->config->expects($this->once()) - ->method('getSystemValueBool') - ->with('has_internet_connection', true) - ->willReturn(true); $this->config->expects($this->exactly(2)) - ->method('getSystemValue') + ->method('getSystemValueBool') ->withConsecutive( ['gs.enabled', false], - ['lookup_server', 'https://lookup.nextcloud.com'], + ['has_internet_connection', true], )->willReturnOnConsecutiveCalls( $GSEnabled, - $searchParams['server'], + true, ); + $this->config->expects($this->once()) + ->method('getSystemValueString') + ->with('lookup_server', 'https://lookup.nextcloud.com') + ->willReturn($searchParams['server']); $response = $this->createMock(IResponse::class); $response->expects($this->once()) @@ -254,10 +254,15 @@ public function testSearchEnableDisableLookupServer(array $searchParams, $GSEnab ->willReturn($client); } else { $searchResult->expects($this->never())->method('addResultSet'); - $this->config->expects($this->once()) - ->method('getSystemValue') - ->with('gs.enabled', false) - ->willReturn($GSEnabled); + $this->config->expects($this->exactly(2)) + ->method('getSystemValueBool') + ->withConsecutive( + ['gs.enabled', false], + ['has_internet_connection', true], + )->willReturnOnConsecutiveCalls( + $GSEnabled, + true, + ); } $moreResults = $this->plugin->search( $searchParams['search'], diff --git a/tests/lib/DB/MigratorTest.php b/tests/lib/DB/MigratorTest.php index 6a2b113a796d3..4d7d9cab19fa9 100644 --- a/tests/lib/DB/MigratorTest.php +++ b/tests/lib/DB/MigratorTest.php @@ -76,7 +76,7 @@ private function getMigrator(): Migrator { } private function getUniqueTableName() { - return strtolower($this->getUniqueID($this->config->getSystemValue('dbtableprefix', 'oc_') . 'test_')); + return strtolower($this->getUniqueID($this->config->getSystemValueString('dbtableprefix', 'oc_') . 'test_')); } protected function tearDown(): void { @@ -160,10 +160,10 @@ public function testUpgrade() { } public function testUpgradeDifferentPrefix() { - $oldTablePrefix = $this->config->getSystemValue('dbtableprefix', 'oc_'); + $oldTablePrefix = $this->config->getSystemValueString('dbtableprefix', 'oc_'); $this->config->setSystemValue('dbtableprefix', 'ownc_'); - $this->tableName = strtolower($this->getUniqueID($this->config->getSystemValue('dbtableprefix') . 'test_')); + $this->tableName = strtolower($this->getUniqueID($this->config->getSystemValueString('dbtableprefix') . 'test_')); [$startSchema, $endSchema] = $this->getDuplicateKeySchemas(); $migrator = $this->getMigrator(); diff --git a/tests/lib/Encryption/Keys/StorageTest.php b/tests/lib/Encryption/Keys/StorageTest.php index d1c0257cc6e87..a47edb3fdd65e 100644 --- a/tests/lib/Encryption/Keys/StorageTest.php +++ b/tests/lib/Encryption/Keys/StorageTest.php @@ -77,7 +77,7 @@ protected function setUp(): void { } public function testSetFileKey() { - $this->config->method('getSystemValue') + $this->config->method('getSystemValueString') ->with('version') ->willReturn('20.0.0.2'); $this->util->expects($this->any()) @@ -103,7 +103,7 @@ public function testSetFileKey() { } public function testSetFileOld() { - $this->config->method('getSystemValue') + $this->config->method('getSystemValueString') ->with('version') ->willReturn('20.0.0.0'); $this->util->expects($this->any()) @@ -145,7 +145,7 @@ public function dataTestGetFileKey() { * @param string $expectedKeyContent */ public function testGetFileKey($path, $strippedPartialName, $originalKeyExists, $expectedKeyContent) { - $this->config->method('getSystemValue') + $this->config->method('getSystemValueString') ->with('version') ->willReturn('20.0.0.2'); $this->util->expects($this->any()) @@ -201,7 +201,7 @@ public function testGetFileKey($path, $strippedPartialName, $originalKeyExists, } public function testSetFileKeySystemWide() { - $this->config->method('getSystemValue') + $this->config->method('getSystemValueString') ->with('version') ->willReturn('20.0.0.2'); @@ -233,7 +233,7 @@ public function testSetFileKeySystemWide() { } public function testGetFileKeySystemWide() { - $this->config->method('getSystemValue') + $this->config->method('getSystemValueString') ->with('version') ->willReturn('20.0.0.2'); @@ -261,7 +261,7 @@ public function testGetFileKeySystemWide() { } public function testSetSystemUserKey() { - $this->config->method('getSystemValue') + $this->config->method('getSystemValueString') ->with('version') ->willReturn('20.0.0.2'); @@ -281,7 +281,7 @@ public function testSetSystemUserKey() { } public function testSetUserKey() { - $this->config->method('getSystemValue') + $this->config->method('getSystemValueString') ->with('version') ->willReturn('20.0.0.2'); @@ -301,7 +301,7 @@ public function testSetUserKey() { } public function testGetSystemUserKey() { - $this->config->method('getSystemValue') + $this->config->method('getSystemValueString') ->with('version') ->willReturn('20.0.0.2'); @@ -324,7 +324,7 @@ public function testGetSystemUserKey() { } public function testGetUserKey() { - $this->config->method('getSystemValue') + $this->config->method('getSystemValueString') ->with('version') ->willReturn('20.0.0.2'); diff --git a/tests/lib/Encryption/ManagerTest.php b/tests/lib/Encryption/ManagerTest.php index 79d2c216080bb..4e354ad518c58 100644 --- a/tests/lib/Encryption/ManagerTest.php +++ b/tests/lib/Encryption/ManagerTest.php @@ -66,7 +66,7 @@ public function testManagerIsDisabledIfDisabledButModules() { } public function testManagerIsEnabled() { - $this->config->expects($this->any())->method('getSystemValue')->willReturn(true); + $this->config->expects($this->any())->method('getSystemValueBool')->willReturn(true); $this->config->expects($this->any())->method('getAppValue')->willReturn('yes'); $this->assertTrue($this->manager->isEnabled()); } @@ -199,7 +199,7 @@ public function testSetDefaultEncryptionModule() { // */ // public function testModuleRegistration() { // $config = $this->createMock(IConfig::class); -// $config->expects($this->any())->method('getSystemValue')->willReturn(true); +// $config->expects($this->any())->method('getSystemValueBool')->willReturn(true); // $em = $this->createMock(IEncryptionModule::class); // $em->expects($this->any())->method('getId')->willReturn(0); // $em->expects($this->any())->method('getDisplayName')->willReturn('TestDummyModule0'); @@ -211,7 +211,7 @@ public function testSetDefaultEncryptionModule() { // // public function testModuleUnRegistration() { // $config = $this->createMock(IConfig::class); -// $config->expects($this->any())->method('getSystemValue')->willReturn(true); +// $config->expects($this->any())->method('getSystemValueBool')->willReturn(true); // $em = $this->createMock(IEncryptionModule::class); // $em->expects($this->any())->method('getId')->willReturn(0); // $em->expects($this->any())->method('getDisplayName')->willReturn('TestDummyModule0'); @@ -228,7 +228,7 @@ public function testSetDefaultEncryptionModule() { // */ // public function testGetEncryptionModuleUnknown() { // $config = $this->createMock(IConfig::class); -// $config->expects($this->any())->method('getSystemValue')->willReturn(true); +// $config->expects($this->any())->method('getSystemValueBool')->willReturn(true); // $em = $this->createMock(IEncryptionModule::class); // $em->expects($this->any())->method('getId')->willReturn(0); // $em->expects($this->any())->method('getDisplayName')->willReturn('TestDummyModule0'); @@ -240,7 +240,7 @@ public function testSetDefaultEncryptionModule() { // // public function testGetEncryptionModule() { // $config = $this->createMock(IConfig::class); -// $config->expects($this->any())->method('getSystemValue')->willReturn(true); +// $config->expects($this->any())->method('getSystemValueBool')->willReturn(true); // $em = $this->createMock(IEncryptionModule::class); // $em->expects($this->any())->method('getId')->willReturn(0); // $em->expects($this->any())->method('getDisplayName')->willReturn('TestDummyModule0'); diff --git a/tests/lib/Files/EtagTest.php b/tests/lib/Files/EtagTest.php index 43b92c12391a3..b9583a6ac7cec 100644 --- a/tests/lib/Files/EtagTest.php +++ b/tests/lib/Files/EtagTest.php @@ -41,7 +41,7 @@ protected function setUp(): void { \OC\Share\Share::registerBackend('folder', 'OCA\Files_Sharing\ShareBackend\Folder', 'file'); $config = \OC::$server->getConfig(); - $this->datadir = $config->getSystemValue('datadirectory'); + $this->datadir = $config->getSystemValueString('datadirectory'); $this->tmpDir = \OC::$server->getTempManager()->getTemporaryFolder(); $config->setSystemValue('datadirectory', $this->tmpDir); diff --git a/tests/lib/Files/FilesystemTest.php b/tests/lib/Files/FilesystemTest.php index 8f34860d85a12..96fcab77474e5 100644 --- a/tests/lib/Files/FilesystemTest.php +++ b/tests/lib/Files/FilesystemTest.php @@ -347,7 +347,7 @@ public function testLocalMountWhenUserDoesNotExist() { \OC\Files\Filesystem::initMountPoints($userId); } - + public function testNullUserThrows() { $this->expectException(\OC\User\NoUserException::class); @@ -427,7 +427,7 @@ public function dummyHook($arguments) { public function testMountDefaultCacheDir() { $userId = $this->getUniqueID('user_'); $config = \OC::$server->getConfig(); - $oldCachePath = $config->getSystemValue('cache_path', ''); + $oldCachePath = $config->getSystemValueString('cache_path', ''); // no cache path configured $config->setSystemValue('cache_path', ''); @@ -457,7 +457,7 @@ public function testMountExternalCacheDir() { $userId = $this->getUniqueID('user_'); $config = \OC::$server->getConfig(); - $oldCachePath = $config->getSystemValue('cache_path', ''); + $oldCachePath = $config->getSystemValueString('cache_path', ''); // set cache path to temp dir $cachePath = \OC::$server->getTempManager()->getTemporaryFolder() . '/extcache'; $config->setSystemValue('cache_path', $cachePath); diff --git a/tests/lib/GlobalScale/ConfigTest.php b/tests/lib/GlobalScale/ConfigTest.php index e67cb392d64bd..826a57a2b302a 100644 --- a/tests/lib/GlobalScale/ConfigTest.php +++ b/tests/lib/GlobalScale/ConfigTest.php @@ -52,7 +52,7 @@ public function getInstance($mockMethods = []) { public function testIsGlobalScaleEnabled() { $gsConfig = $this->getInstance(); - $this->config->expects($this->once())->method('getSystemValue') + $this->config->expects($this->once())->method('getSystemValueBool') ->with('gs.enabled', false)->willReturn(true); $result = $gsConfig->isGlobalScaleEnabled(); @@ -73,7 +73,7 @@ public function testOnlyInternalFederation($gsEnabled, $gsFederation, $expected) $gsConfig->expects($this->any())->method('isGlobalScaleEnabled')->willReturn($gsEnabled); - $this->config->expects($this->any())->method('getSystemValue') + $this->config->expects($this->any())->method('getSystemValueString') ->with('gs.federation', 'internal')->willReturn($gsFederation); $this->assertSame($expected, $gsConfig->onlyInternalFederation()); diff --git a/tests/lib/Http/Client/ClientTest.php b/tests/lib/Http/Client/ClientTest.php index 93948a5daf3de..9a4fb1c657e0f 100644 --- a/tests/lib/Http/Client/ClientTest.php +++ b/tests/lib/Http/Client/ClientTest.php @@ -54,22 +54,25 @@ protected function setUp(): void { public function testGetProxyUri(): void { $this->config - ->method('getSystemValue') - ->with('proxy', null) - ->willReturn(null); + ->method('getSystemValueString') + ->with('proxy', '') + ->willReturn(''); $this->assertNull(self::invokePrivate($this->client, 'getProxyUri')); } public function testGetProxyUriProxyHostEmptyPassword(): void { - $map = [ - ['proxy', '', 'foo'], - ['proxyuserpwd', '', null], - ['proxyexclude', [], []], - ]; - $this->config ->method('getSystemValue') - ->will($this->returnValueMap($map)); + ->will($this->returnValueMap([ + ['proxyexclude', [], []], + ])); + + $this->config + ->method('getSystemValueString') + ->will($this->returnValueMap([ + ['proxy', '', 'foo'], + ['proxyuserpwd', '', ''], + ])); $this->assertEquals([ 'http' => 'foo', @@ -79,32 +82,20 @@ public function testGetProxyUriProxyHostEmptyPassword(): void { public function testGetProxyUriProxyHostWithPassword(): void { $this->config - ->expects($this->exactly(3)) + ->expects($this->once()) ->method('getSystemValue') + ->with('proxyexclude', []) + ->willReturn([]); + $this->config + ->expects($this->exactly(2)) + ->method('getSystemValueString') ->withConsecutive( - [ - $this->equalTo('proxy'), - $this->callback(function ($input) { - return $input === ''; - }) - ], - [ - $this->equalTo('proxyuserpwd'), - $this->callback(function ($input) { - return $input === ''; - }) - ], - [ - $this->equalTo('proxyexclude'), - $this->callback(function ($input) { - return $input === []; - }) - ], + ['proxy', ''], + ['proxyuserpwd', ''], ) ->willReturnOnConsecutiveCalls( 'foo', 'username:password', - [], ); $this->assertEquals([ 'http' => 'username:password@foo', @@ -114,32 +105,20 @@ public function testGetProxyUriProxyHostWithPassword(): void { public function testGetProxyUriProxyHostWithPasswordAndExclude(): void { $this->config - ->expects($this->exactly(3)) + ->expects($this->once()) ->method('getSystemValue') + ->with('proxyexclude', []) + ->willReturn(['bar']); + $this->config + ->expects($this->exactly(2)) + ->method('getSystemValueString') ->withConsecutive( - [ - $this->equalTo('proxy'), - $this->callback(function ($input) { - return $input === ''; - }) - ], - [ - $this->equalTo('proxyuserpwd'), - $this->callback(function ($input) { - return $input === ''; - }) - ], - [ - $this->equalTo('proxyexclude'), - $this->callback(function ($input) { - return $input === []; - }) - ], + ['proxy', ''], + ['proxyuserpwd', ''], ) ->willReturnOnConsecutiveCalls( 'foo', 'username:password', - ['bar'], ); $this->assertEquals([ 'http' => 'username:password@foo', @@ -271,19 +250,23 @@ public function testPreventLocalAddressOnDelete(string $uri): void { } private function setUpDefaultRequestOptions(): void { - $map = [ - ['proxy', '', 'foo'], - ['proxyuserpwd', '', null], - ['proxyexclude', [], []], - ]; - $this->config ->method('getSystemValue') - ->will($this->returnValueMap($map)); + ->will($this->returnValueMap([ + ['proxyexclude', [], []], + ])); + $this->config + ->method('getSystemValueString') + ->will($this->returnValueMap([ + ['proxy', '', 'foo'], + ['proxyuserpwd', '', ''], + ])); $this->config ->method('getSystemValueBool') - ->with('allow_local_remote_servers', false) - ->willReturn(true); + ->will($this->returnValueMap([ + ['installed', false, true], + ['allow_local_remote_servers', false, true], + ])); $this->certificateManager ->expects($this->once()) @@ -467,15 +450,20 @@ public function testHeadWithOptions(): void { public function testSetDefaultOptionsWithNotInstalled(): void { $this->config ->expects($this->exactly(2)) - ->method('getSystemValue') + ->method('getSystemValueBool') ->withConsecutive( - ['proxy', ''], ['installed', false], + ['allow_local_remote_servers', false], ) ->willReturnOnConsecutiveCalls( - '', + false, false, ); + $this->config + ->expects($this->once()) + ->method('getSystemValueString') + ->with('proxy', '') + ->willReturn(''); $this->certificateManager ->expects($this->never()) ->method('listCertificates'); @@ -503,19 +491,31 @@ public function testSetDefaultOptionsWithNotInstalled(): void { public function testSetDefaultOptionsWithProxy(): void { $this->config - ->expects($this->exactly(4)) + ->expects($this->exactly(2)) + ->method('getSystemValueBool') + ->withConsecutive( + ['installed', false], + ['allow_local_remote_servers', false], + ) + ->willReturnOnConsecutiveCalls( + true, + false, + ); + $this->config + ->expects($this->once()) ->method('getSystemValue') + ->with('proxyexclude', []) + ->willReturn([]); + $this->config + ->expects($this->exactly(2)) + ->method('getSystemValueString') ->withConsecutive( ['proxy', ''], ['proxyuserpwd', ''], - ['proxyexclude', []], - ['installed', false], ) ->willReturnOnConsecutiveCalls( 'foo', '', - [], - true, ); $this->certificateManager ->expects($this->once()) @@ -550,19 +550,31 @@ public function testSetDefaultOptionsWithProxy(): void { public function testSetDefaultOptionsWithProxyAndExclude(): void { $this->config - ->expects($this->exactly(4)) + ->expects($this->exactly(2)) + ->method('getSystemValueBool') + ->withConsecutive( + ['installed', false], + ['allow_local_remote_servers', false], + ) + ->willReturnOnConsecutiveCalls( + true, + false, + ); + $this->config + ->expects($this->once()) ->method('getSystemValue') + ->with('proxyexclude', []) + ->willReturn(['bar']); + $this->config + ->expects($this->exactly(2)) + ->method('getSystemValueString') ->withConsecutive( ['proxy', ''], ['proxyuserpwd', ''], - ['proxyexclude', []], - ['installed', false], ) ->willReturnOnConsecutiveCalls( 'foo', '', - ['bar'], - true, ); $this->certificateManager ->expects($this->once()) diff --git a/tests/lib/IntegrityCheck/CheckerTest.php b/tests/lib/IntegrityCheck/CheckerTest.php index 62938ad6c1b0e..203e7e9722715 100644 --- a/tests/lib/IntegrityCheck/CheckerTest.php +++ b/tests/lib/IntegrityCheck/CheckerTest.php @@ -164,7 +164,7 @@ public function testVerifyAppSignatureWithoutSignatureData() { ->willReturn('stable'); $this->config ->expects($this->any()) - ->method('getSystemValue') + ->method('getSystemValueBool') ->with('integrity.check.disabled', false) ->willReturn(false); @@ -184,7 +184,7 @@ public function testVerifyAppSignatureWithValidSignatureData() { ->willReturn('stable'); $this->config ->expects($this->any()) - ->method('getSystemValue') + ->method('getSystemValueBool') ->with('integrity.check.disabled', false) ->willReturn(false); @@ -223,7 +223,7 @@ public function testVerifyAppSignatureWithTamperedSignatureData() { ->willReturn('stable'); $this->config ->expects($this->any()) - ->method('getSystemValue') + ->method('getSystemValueBool') ->with('integrity.check.disabled', false) ->willReturn(false); @@ -268,7 +268,7 @@ public function testVerifyAppSignatureWithTamperedFiles() { ->willReturn('stable'); $this->config ->expects($this->any()) - ->method('getSystemValue') + ->method('getSystemValueBool') ->with('integrity.check.disabled', false) ->willReturn(false); @@ -329,7 +329,7 @@ public function testVerifyAppSignatureWithTamperedFilesAndAlternatePath() { ->willReturn('stable'); $this->config ->expects($this->any()) - ->method('getSystemValue') + ->method('getSystemValueBool') ->with('integrity.check.disabled', false) ->willReturn(false); @@ -389,7 +389,7 @@ public function testVerifyAppWithDifferentScope() { ->willReturn('stable'); $this->config ->expects($this->any()) - ->method('getSystemValue') + ->method('getSystemValueBool') ->with('integrity.check.disabled', false) ->willReturn(false); @@ -433,7 +433,7 @@ public function testVerifyAppWithDifferentScopeAndAlwaysTrustedCore() { ->willReturn('stable'); $this->config ->expects($this->any()) - ->method('getSystemValue') + ->method('getSystemValueBool') ->with('integrity.check.disabled', false) ->willReturn(false); @@ -654,7 +654,7 @@ public function testVerifyCoreSignatureWithoutSignatureData() { ->willReturn('stable'); $this->config ->expects($this->any()) - ->method('getSystemValue') + ->method('getSystemValueBool') ->with('integrity.check.disabled', false) ->willReturn(false); @@ -674,7 +674,7 @@ public function testVerifyCoreSignatureWithValidSignatureData() { ->willReturn('stable'); $this->config ->expects($this->any()) - ->method('getSystemValue') + ->method('getSystemValueBool') ->with('integrity.check.disabled', false) ->willReturn(false); @@ -711,7 +711,7 @@ public function testVerifyCoreSignatureWithValidModifiedHtaccessSignatureData() ->willReturn('stable'); $this->config ->expects($this->any()) - ->method('getSystemValue') + ->method('getSystemValueBool') ->with('integrity.check.disabled', false) ->willReturn(false); @@ -774,7 +774,7 @@ public function testVerifyCoreSignatureWithModifiedMimetypelistSignatureData() { ->willReturn('stable'); $this->config ->expects($this->any()) - ->method('getSystemValue') + ->method('getSystemValueBool') ->with('integrity.check.disabled', false) ->willReturn(false); @@ -801,7 +801,7 @@ public function testVerifyCoreSignatureWithValidSignatureDataAndNotAlphabeticOrd ->willReturn('stable'); $this->config ->expects($this->any()) - ->method('getSystemValue') + ->method('getSystemValueBool') ->with('integrity.check.disabled', false) ->willReturn(false); @@ -838,7 +838,7 @@ public function testVerifyCoreSignatureWithTamperedSignatureData() { ->willReturn('stable'); $this->config ->expects($this->any()) - ->method('getSystemValue') + ->method('getSystemValueBool') ->with('integrity.check.disabled', false) ->willReturn(false); @@ -881,7 +881,7 @@ public function testVerifyCoreSignatureWithTamperedFiles() { ->willReturn('stable'); $this->config ->expects($this->any()) - ->method('getSystemValue') + ->method('getSystemValueBool') ->with('integrity.check.disabled', false) ->willReturn(false); @@ -939,7 +939,7 @@ public function testVerifyCoreWithInvalidCertificate() { ->willReturn('stable'); $this->config ->expects($this->any()) - ->method('getSystemValue') + ->method('getSystemValueBool') ->with('integrity.check.disabled', false) ->willReturn(false); @@ -982,7 +982,7 @@ public function testVerifyCoreWithDifferentScope() { ->willReturn('stable'); $this->config ->expects($this->any()) - ->method('getSystemValue') + ->method('getSystemValueBool') ->with('integrity.check.disabled', false) ->willReturn(false); @@ -1104,7 +1104,7 @@ public function testVerifyAppSignatureWithoutSignatureDataAndCodeCheckerDisabled ->willReturn('stable'); $this->config ->expects($this->any()) - ->method('getSystemValue') + ->method('getSystemValueBool') ->with('integrity.check.disabled', false) ->willReturn(true); @@ -1134,7 +1134,7 @@ public function testIsCodeCheckEnforced($channel, $isCodeSigningEnforced) { ->willReturn($channel); $this->config ->expects($this->any()) - ->method('getSystemValue') + ->method('getSystemValueBool') ->with('integrity.check.disabled', false) ->willReturn(false); @@ -1152,7 +1152,7 @@ public function testIsCodeCheckEnforcedWithDisabledConfigSwitch($channel) { ->willReturn($channel); $this->config ->expects($this->any()) - ->method('getSystemValue') + ->method('getSystemValueBool') ->with('integrity.check.disabled', false) ->willReturn(true); diff --git a/tests/lib/L10N/FactoryTest.php b/tests/lib/L10N/FactoryTest.php index 0b536971e9003..2db1e0302e8a5 100644 --- a/tests/lib/L10N/FactoryTest.php +++ b/tests/lib/L10N/FactoryTest.php @@ -47,6 +47,12 @@ protected function setUp(): void { $this->cacheFactory = $this->createMock(ICacheFactory::class); $this->serverRoot = \OC::$SERVERROOT; + + $this->config + ->method('getSystemValueBool') + ->willReturnMap([ + ['installed', false, true], + ]); } /** @@ -121,14 +127,12 @@ public function testFindLanguageWithNotExistingRequestLanguageAndExistingStoredU true, ); $this->config - ->expects($this->exactly(2)) + ->expects($this->exactly(1)) ->method('getSystemValue') ->withConsecutive( ['force_language', false], - ['installed', false], )->willReturnOnConsecutiveCalls( false, - true, ); $user = $this->getMockBuilder(IUser::class) ->getMock(); @@ -159,11 +163,10 @@ public function testFindLanguageWithNotExistingRequestLanguageAndNotExistingStor ['MyApp', 'es', true], ]); $this->config - ->expects($this->exactly(3)) + ->expects($this->exactly(2)) ->method('getSystemValue') ->willReturnMap([ ['force_language', false, false], - ['installed', false, true], ['default_language', false, 'es'] ]); $user = $this->getMockBuilder(IUser::class) @@ -195,11 +198,10 @@ public function testFindLanguageWithNotExistingRequestLanguageAndNotExistingStor ['MyApp', 'es', false], ]); $this->config - ->expects($this->exactly(3)) + ->expects($this->exactly(2)) ->method('getSystemValue') ->willReturnMap([ ['force_language', false, false], - ['installed', false, true], ['default_language', false, 'es'] ]); $user = $this->getMockBuilder(IUser::class) @@ -234,11 +236,10 @@ public function testFindLanguageWithNotExistingRequestLanguageAndNotExistingStor ['MyApp', 'es', false], ]); $this->config - ->expects($this->exactly(3)) + ->expects($this->exactly(2)) ->method('getSystemValue') ->willReturnMap([ ['force_language', false, false], - ['installed', false, true], ['default_language', false, 'es'] ]); $user = $this->getMockBuilder(IUser::class) @@ -319,7 +320,7 @@ public function testFindAvailableLanguagesWithThemes(): void { ->willReturn($this->serverRoot . '/apps/files/l10n/'); $this->config ->expects(self::once()) - ->method('getSystemValue') + ->method('getSystemValueString') ->with('theme') ->willReturn('abc'); @@ -474,9 +475,7 @@ public function testFindLanguage($loggedIn, $availableLang, $expected): void { $this->config->expects(self::any()) ->method('getSystemValue') ->willReturnCallback(function ($var, $default) use ($defaultLang) { - if ($var === 'installed') { - return true; - } elseif ($var === 'default_language') { + if ($var === 'default_language') { return $defaultLang; } else { return $default; @@ -562,12 +561,11 @@ public function testFindGenericLanguageByDefaultLanguage(): void { public function testFindGenericLanguageByUserLanguage(): void { $factory = $this->getFactory(); - $this->config->expects(self::exactly(3)) + $this->config->expects(self::exactly(2)) ->method('getSystemValue') ->willReturnMap([ ['force_language', false, false,], ['default_language', false, false,], - ['installed', false, true], ]); $user = $this->createMock(IUser::class); $this->userSession->expects(self::once()) @@ -590,7 +588,6 @@ public function testFindGenericLanguageByRequestLanguage(): void { ->willReturnMap([ ['force_language', false, false,], ['default_language', false, false,], - ['installed', false, true], ]); $user = $this->createMock(IUser::class); $this->userSession->expects(self::once()) @@ -621,7 +618,6 @@ public function testFindGenericLanguageFallback(): void { ->willReturnMap([ ['force_language', false, false,], ['default_language', false, false,], - ['installed', false, true], ]); $user = $this->createMock(IUser::class); $this->userSession->expects(self::once()) diff --git a/tests/lib/L10N/LanguageIteratorTest.php b/tests/lib/L10N/LanguageIteratorTest.php index bbbbb145c7545..1d5335cebaaa5 100644 --- a/tests/lib/L10N/LanguageIteratorTest.php +++ b/tests/lib/L10N/LanguageIteratorTest.php @@ -82,6 +82,10 @@ public function testIterator($forcedLang, $userLang, $sysLang, $expectedValues) ->method('getSystemValue') ->willReturnMap([ ['force_language', false, $forcedLang], + ]); + $this->config->expects($this->any()) + ->method('getSystemValueString') + ->willReturnMap([ ['default_language', 'en', $sysLang], ]); $this->config->expects($this->any()) diff --git a/tests/lib/Mail/MailerTest.php b/tests/lib/Mail/MailerTest.php index 39e4d689a3709..ba1d52f4bafc0 100644 --- a/tests/lib/Mail/MailerTest.php +++ b/tests/lib/Mail/MailerTest.php @@ -84,7 +84,7 @@ public function sendmailModeProvider(): array { public function testGetSendmailInstanceSendMail($sendmailMode, $binaryParam) { $this->config ->expects($this->exactly(2)) - ->method('getSystemValue') + ->method('getSystemValueString') ->willReturnMap([ ['mail_smtpmode', 'smtp', 'sendmail'], ['mail_sendmailmode', 'smtp', $sendmailMode], @@ -107,7 +107,7 @@ public function testGetSendmailInstanceSendMail($sendmailMode, $binaryParam) { public function testGetSendmailInstanceSendMailQmail($sendmailMode, $binaryParam) { $this->config ->expects($this->exactly(2)) - ->method('getSystemValue') + ->method('getSystemValueString') ->willReturnMap([ ['mail_smtpmode', 'smtp', 'qmail'], ['mail_sendmailmode', 'smtp', $sendmailMode], @@ -133,7 +133,7 @@ public function testGetInstanceDefault() { public function testGetInstanceSendmail() { $this->config - ->method('getSystemValue') + ->method('getSystemValueString') ->willReturnMap([ ['mail_smtpmode', 'smtp', 'sendmail'], ['mail_sendmailmode', 'smtp', 'smtp'], @@ -180,7 +180,7 @@ public function testEvents() { public function testCreateMessage() { $this->config ->expects($this->any()) - ->method('getSystemValue') + ->method('getSystemValueBool') ->with('mail_send_plaintext_only', false) ->willReturn(false); $this->assertInstanceOf('\OC\Mail\Message', $this->mailer->createMessage()); @@ -229,7 +229,7 @@ public function testValidateMailAddress($email, $expected) { } public function testCreateEMailTemplate() { - $this->config->method('getSystemValue') + $this->config->method('getSystemValueString') ->with('mail_template_class', '') ->willReturnArgument(1); @@ -239,12 +239,16 @@ public function testCreateEMailTemplate() { public function testStreamingOptions() { $this->config->method('getSystemValue') ->willReturnMap([ - ['mail_smtpmode', 'smtp', 'smtp'], ['mail_smtpstreamoptions', [], ['foo' => 1]], ['mail_smtphost', '127.0.0.1', '127.0.0.1'], ['mail_smtpport', 25, 25], ['mail_smtptimeout', 10, 10], ]); + $this->config->method('getSystemValueString') + ->willReturnMap([ + ['mail_smtpmode', 'smtp', 'smtp'], + ['overwrite.cli.url', '', ''], + ]); $mailer = self::invokePrivate($this->mailer, 'getInstance'); /** @var EsmtpTransport $transport */ $transport = self::invokePrivate($mailer, 'transport'); @@ -256,12 +260,16 @@ public function testStreamingOptions() { public function testStreamingOptionsWrongType() { $this->config->method('getSystemValue') ->willReturnMap([ - ['mail_smtpmode', 'smtp', 'smtp'], ['mail_smtpstreamoptions', [], 'bar'], ['mail_smtphost', '127.0.0.1', '127.0.0.1'], ['mail_smtpport', 25, 25], ['mail_smtptimeout', 10, 10], ]); + $this->config->method('getSystemValueString') + ->willReturnMap([ + ['mail_smtpmode', 'smtp', 'smtp'], + ['overwrite.cli.url', '', ''], + ]); $mailer = self::invokePrivate($this->mailer, 'getInstance'); /** @var EsmtpTransport $transport */ $transport = self::invokePrivate($mailer, 'transport'); @@ -272,14 +280,15 @@ public function testStreamingOptionsWrongType() { public function testLocalDomain(): void { $this->config->method('getSystemValue') ->willReturnMap([ - ['mail_smtpmode', 'smtp', 'smtp'], ['mail_smtphost', '127.0.0.1', '127.0.0.1'], ['mail_smtpport', 25, 25], ['mail_smtptimeout', 10, 10], ]); $this->config->method('getSystemValueString') - ->with('overwrite.cli.url', '') - ->willReturn('https://some.valid.url.com:8080'); + ->willReturnMap([ + ['mail_smtpmode', 'smtp', 'smtp'], + ['overwrite.cli.url', '', 'https://some.valid.url.com:8080'], + ]); /** @var SymfonyMailer $mailer */ $mailer = self::invokePrivate($this->mailer, 'getInstance'); @@ -294,14 +303,15 @@ public function testLocalDomain(): void { public function testLocalDomainInvalidUrl(): void { $this->config->method('getSystemValue') ->willReturnMap([ - ['mail_smtpmode', 'smtp', 'smtp'], - ['mail_smtphost', '127.0.0.1', '127.0.0.1'], ['mail_smtpport', 25, 25], ['mail_smtptimeout', 10, 10], + ['mail_smtphost', '127.0.0.1', '127.0.0.1'], ]); $this->config->method('getSystemValueString') - ->with('overwrite.cli.url', '') - ->willReturn('https:only.slash.does.not.work:8080'); + ->willReturnMap([ + ['mail_smtpmode', 'smtp', 'smtp'], + ['overwrite.cli.url', '', 'https:only.slash.does.not.work:8080'], + ]); /** @var SymfonyMailer $mailer */ $mailer = self::invokePrivate($this->mailer, 'getInstance'); diff --git a/tests/lib/Repair/ClearGeneratedAvatarCacheTest.php b/tests/lib/Repair/ClearGeneratedAvatarCacheTest.php index 7aa7831e44eb0..44fc709c72af3 100644 --- a/tests/lib/Repair/ClearGeneratedAvatarCacheTest.php +++ b/tests/lib/Repair/ClearGeneratedAvatarCacheTest.php @@ -76,7 +76,7 @@ public function shouldRunDataProvider() { */ public function testShouldRun($from, $expected) { $this->config->expects($this->any()) - ->method('getSystemValue') + ->method('getSystemValueString') ->with('version', '0.0.0.0') ->willReturn($from); diff --git a/tests/lib/Repair/RepairCollationTest.php b/tests/lib/Repair/RepairCollationTest.php index 902ddcd453987..9e76a81080f97 100644 --- a/tests/lib/Repair/RepairCollationTest.php +++ b/tests/lib/Repair/RepairCollationTest.php @@ -66,7 +66,7 @@ protected function setUp(): void { $this->markTestSkipped("Test only relevant on MySql"); } - $dbPrefix = $this->config->getSystemValue("dbtableprefix"); + $dbPrefix = $this->config->getSystemValueString("dbtableprefix"); $this->tableName = $this->getUniqueID($dbPrefix . "_collation_test"); $this->connection->prepare("CREATE TABLE $this->tableName(text VARCHAR(16)) COLLATE utf8_unicode_ci")->execute(); diff --git a/tests/lib/Repair/RepairDavSharesTest.php b/tests/lib/Repair/RepairDavSharesTest.php index 5eeafd7bf9fc5..394fc9854690d 100644 --- a/tests/lib/Repair/RepairDavSharesTest.php +++ b/tests/lib/Repair/RepairDavSharesTest.php @@ -71,7 +71,7 @@ public function setUp(): void { public function testRun() { $this->config->expects($this->any()) - ->method('getSystemValue') + ->method('getSystemValueString') ->with('version', '0.0.0') ->willReturn('20.0.2'); diff --git a/tests/lib/Repair/RepairInvalidSharesTest.php b/tests/lib/Repair/RepairInvalidSharesTest.php index f93940cc3edbe..486e11230b847 100644 --- a/tests/lib/Repair/RepairInvalidSharesTest.php +++ b/tests/lib/Repair/RepairInvalidSharesTest.php @@ -36,7 +36,7 @@ protected function setUp(): void { ->disableOriginalConstructor() ->getMock(); $config->expects($this->any()) - ->method('getSystemValue') + ->method('getSystemValueString') ->with('version') ->willReturn('12.0.0.0'); diff --git a/tests/lib/Repair/RepairMimeTypesTest.php b/tests/lib/Repair/RepairMimeTypesTest.php index 176bc0ec102d9..61cf58582414e 100644 --- a/tests/lib/Repair/RepairMimeTypesTest.php +++ b/tests/lib/Repair/RepairMimeTypesTest.php @@ -42,7 +42,7 @@ protected function setUp(): void { ->disableOriginalConstructor() ->getMock(); $config->expects($this->any()) - ->method('getSystemValue') + ->method('getSystemValueString') ->with('version') ->willReturn('11.0.0.0'); diff --git a/tests/lib/Repair/RepairSqliteAutoincrementTest.php b/tests/lib/Repair/RepairSqliteAutoincrementTest.php index 5b3a388dea3af..b4be47d015735 100644 --- a/tests/lib/Repair/RepairSqliteAutoincrementTest.php +++ b/tests/lib/Repair/RepairSqliteAutoincrementTest.php @@ -46,7 +46,7 @@ protected function setUp(): void { $this->markTestSkipped("Test only relevant on Sqlite"); } - $dbPrefix = $this->config->getSystemValue('dbtableprefix', 'oc_'); + $dbPrefix = $this->config->getSystemValueString('dbtableprefix', 'oc_'); $this->tableName = $this->getUniqueID($dbPrefix . 'autoinc_test'); $this->connection->prepare('CREATE TABLE ' . $this->tableName . '("someid" INTEGER NOT NULL, "text" VARCHAR(16), PRIMARY KEY("someid"))')->execute(); diff --git a/tests/lib/Security/Bruteforce/ThrottlerTest.php b/tests/lib/Security/Bruteforce/ThrottlerTest.php index 6639f884ae126..f23b15a06d70a 100644 --- a/tests/lib/Security/Bruteforce/ThrottlerTest.php +++ b/tests/lib/Security/Bruteforce/ThrottlerTest.php @@ -183,7 +183,7 @@ private function isIpWhiteListedHelper($ip, ->willReturn(array_keys($whitelists)); $this->config ->expects($this->once()) - ->method('getSystemValue') + ->method('getSystemValueBool') ->with('auth.bruteforce.protection.enabled', true) ->willReturn($enabled); diff --git a/tests/lib/Security/CertificateManagerTest.php b/tests/lib/Security/CertificateManagerTest.php index fdc6b40533eb9..6ad8231a61de3 100644 --- a/tests/lib/Security/CertificateManagerTest.php +++ b/tests/lib/Security/CertificateManagerTest.php @@ -48,7 +48,7 @@ protected function setUp(): void { \OC_Util::setupFS($this->username); $config = $this->createMock(IConfig::class); - $config->expects($this->any())->method('getSystemValue') + $config->expects($this->any())->method('getSystemValueBool') ->with('installed', false)->willReturn(true); $this->random = $this->createMock(ISecureRandom::class); diff --git a/tests/lib/Security/HasherTest.php b/tests/lib/Security/HasherTest.php index 37e2adcc13cbc..3848b216f2b70 100644 --- a/tests/lib/Security/HasherTest.php +++ b/tests/lib/Security/HasherTest.php @@ -209,7 +209,7 @@ public function testUsePasswordDefaultArgon2iVerify() { $this->markTestSkipped('Need ARGON2 support to test ARGON2 hashes'); } - $this->config->method('getSystemValue') + $this->config->method('getSystemValueBool') ->with('hashing_default_password') ->willReturn(true); @@ -233,7 +233,7 @@ public function testDoNotUsePasswordDefaultArgon2idVerify() { $this->markTestSkipped('Need ARGON2ID support to test ARGON2ID hashes'); } - $this->config->method('getSystemValue') + $this->config->method('getSystemValueBool') ->with('hashing_default_password') ->willReturn(false); @@ -251,7 +251,7 @@ public function testHashUsePasswordDefault() { $this->markTestSkipped('Need ARGON2 support to test ARGON2 hashes'); } - $this->config->method('getSystemValue') + $this->config->method('getSystemValueBool') ->with('hashing_default_password') ->willReturn(true); diff --git a/tests/lib/Security/VerificationToken/VerificationTokenTest.php b/tests/lib/Security/VerificationToken/VerificationTokenTest.php index 481646f26aba2..a71d2b09f713e 100644 --- a/tests/lib/Security/VerificationToken/VerificationTokenTest.php +++ b/tests/lib/Security/VerificationToken/VerificationTokenTest.php @@ -116,7 +116,7 @@ public function testTokenDecryptionError() { ->with('alice', 'core', 'fingerprintToken', null) ->willReturn('encryptedToken'); $this->config->expects($this->any()) - ->method('getSystemValue') + ->method('getSystemValueString') ->with('secret') ->willReturn('357111317'); @@ -143,7 +143,7 @@ public function testTokenInvalidFormat() { ->with('alice', 'core', 'fingerprintToken', null) ->willReturn('encryptedToken'); $this->config->expects($this->any()) - ->method('getSystemValue') + ->method('getSystemValueString') ->with('secret') ->willReturn('357111317'); @@ -173,7 +173,7 @@ public function testTokenExpired() { ->with('alice', 'core', 'fingerprintToken', null) ->willReturn('encryptedToken'); $this->config->expects($this->any()) - ->method('getSystemValue') + ->method('getSystemValueString') ->with('secret') ->willReturn('357111317'); @@ -207,7 +207,7 @@ public function testTokenExpiredByLogin() { ->with('alice', 'core', 'fingerprintToken', null) ->willReturn('encryptedToken'); $this->config->expects($this->any()) - ->method('getSystemValue') + ->method('getSystemValueString') ->with('secret') ->willReturn('357111317'); @@ -241,7 +241,7 @@ public function testTokenMismatch() { ->with('alice', 'core', 'fingerprintToken', null) ->willReturn('encryptedToken'); $this->config->expects($this->any()) - ->method('getSystemValue') + ->method('getSystemValueString') ->with('secret') ->willReturn('357111317'); @@ -275,7 +275,7 @@ public function testTokenSuccess() { ->with('alice', 'core', 'fingerprintToken', null) ->willReturn('encryptedToken'); $this->config->expects($this->any()) - ->method('getSystemValue') + ->method('getSystemValueString') ->with('secret') ->willReturn('357111317'); diff --git a/tests/lib/Support/Subscription/RegistryTest.php b/tests/lib/Support/Subscription/RegistryTest.php index f4a278cca4e6d..2a6d5e5569f91 100644 --- a/tests/lib/Support/Subscription/RegistryTest.php +++ b/tests/lib/Support/Subscription/RegistryTest.php @@ -206,7 +206,7 @@ public function testDelegateIsHardUserLimitReachedWithoutSupportAppAndUserCount( ->with('one-click-instance') ->willReturn(true); $this->config->expects($this->once()) - ->method('getSystemValue') + ->method('getSystemValueInt') ->with('one-click-instance.user-limit') ->willReturn($userLimit); $this->config->expects($this->once()) diff --git a/tests/lib/TestCase.php b/tests/lib/TestCase.php index 256fb95a85be1..a242a51a8875b 100644 --- a/tests/lib/TestCase.php +++ b/tests/lib/TestCase.php @@ -266,7 +266,7 @@ public static function tearDownAfterClass(): void { return self::$realDatabase; }); } - $dataDir = \OC::$server->getConfig()->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data-autotest'); + $dataDir = \OC::$server->getConfig()->getSystemValueString('datadirectory', \OC::$SERVERROOT . '/data-autotest'); if (self::$wasDatabaseAllowed && \OC::$server->getDatabaseConnection()) { $db = \OC::$server->getDatabaseConnection(); if ($db->inTransaction()) { diff --git a/tests/lib/Updater/VersionCheckTest.php b/tests/lib/Updater/VersionCheckTest.php index 85c74db2ca685..1cd632875c393 100644 --- a/tests/lib/Updater/VersionCheckTest.php +++ b/tests/lib/Updater/VersionCheckTest.php @@ -118,7 +118,7 @@ public function testCheckWithoutUpdateUrl() { ); $this->config ->expects($this->once()) - ->method('getSystemValue') + ->method('getSystemValueString') ->with('updater.server.url', 'https://updates.nextcloud.com/updater_server/') ->willReturnArgument(1); $this->config @@ -170,7 +170,7 @@ public function testCheckWithInvalidXml() { ); $this->config ->expects($this->once()) - ->method('getSystemValue') + ->method('getSystemValueString') ->with('updater.server.url', 'https://updates.nextcloud.com/updater_server/') ->willReturnArgument(1); $this->config @@ -224,7 +224,7 @@ public function testCheckWithEmptyValidXmlResponse() { ); $this->config ->expects($this->once()) - ->method('getSystemValue') + ->method('getSystemValueString') ->with('updater.server.url', 'https://updates.nextcloud.com/updater_server/') ->willReturnArgument(1); $this->config @@ -277,7 +277,7 @@ public function testCheckWithEmptyInvalidXmlResponse() { ); $this->config ->expects($this->once()) - ->method('getSystemValue') + ->method('getSystemValueString') ->with('updater.server.url', 'https://updates.nextcloud.com/updater_server/') ->willReturnArgument(1); $this->config @@ -331,7 +331,7 @@ public function testCheckWithMissingAttributeXmlResponse() { ); $this->config ->expects($this->once()) - ->method('getSystemValue') + ->method('getSystemValueString') ->with('updater.server.url', 'https://updates.nextcloud.com/updater_server/') ->willReturnArgument(1); $this->config diff --git a/tests/lib/UpdaterTest.php b/tests/lib/UpdaterTest.php index 5a7422cbad5e0..579761208db16 100644 --- a/tests/lib/UpdaterTest.php +++ b/tests/lib/UpdaterTest.php @@ -105,7 +105,7 @@ public function versionCompatibilityTestData() { */ public function testIsUpgradePossible($oldVersion, $newVersion, $allowedVersions, $result, $debug = false, $vendor = 'nextcloud') { $this->config->expects($this->any()) - ->method('getSystemValue') + ->method('getSystemValueBool') ->with('debug', false) ->willReturn($debug); $this->config->expects($this->any()) diff --git a/tests/lib/UrlGeneratorTest.php b/tests/lib/UrlGeneratorTest.php index 523616b45328a..b95cb115217fa 100644 --- a/tests/lib/UrlGeneratorTest.php +++ b/tests/lib/UrlGeneratorTest.php @@ -222,7 +222,7 @@ private function mockLinkToDefaultPageUrl(bool $ignoreFrontControllerConfig = fa ->willReturn(''); $this->config->expects($this->once()) - ->method('getSystemValue') + ->method('getSystemValueBool') ->with('htaccess.IgnoreFrontController', $this->anything()) ->willReturn($ignoreFrontControllerConfig); } diff --git a/tests/lib/User/SessionTest.php b/tests/lib/User/SessionTest.php index 4928744ed1c4c..e0afb5330d9ad 100644 --- a/tests/lib/User/SessionTest.php +++ b/tests/lib/User/SessionTest.php @@ -353,7 +353,7 @@ public function testLogClientInNoTokenPasswordWith2fa() { ->with('doe') ->will($this->throwException(new InvalidTokenException())); $this->config->expects($this->once()) - ->method('getSystemValue') + ->method('getSystemValueBool') ->with('token_auth_enforced', false) ->willReturn(true); $request @@ -389,7 +389,7 @@ public function testLogClientInUnexist() { ->with('doe') ->will($this->throwException(new InvalidTokenException())); $this->config->expects($this->once()) - ->method('getSystemValue') + ->method('getSystemValueBool') ->with('token_auth_enforced', false) ->willReturn(false); $manager->method('getByEmail') @@ -457,7 +457,7 @@ public function testLogClientInNoTokenPasswordNo2fa() { ->with('doe') ->will($this->throwException(new InvalidTokenException())); $this->config->expects($this->once()) - ->method('getSystemValue') + ->method('getSystemValueBool') ->with('token_auth_enforced', false) ->willReturn(false); diff --git a/tests/lib/User/UserTest.php b/tests/lib/User/UserTest.php index b8fa8efced0c0..7f4ca97e18bbc 100644 --- a/tests/lib/User/UserTest.php +++ b/tests/lib/User/UserTest.php @@ -306,7 +306,7 @@ public function testGetHomeNotSupported() { ->method('getUserValue') ->willReturn(true); $allConfig->expects($this->any()) - ->method('getSystemValue') + ->method('getSystemValueString') ->with($this->equalTo('datadirectory')) ->willReturn('arbitrary/path'); @@ -364,7 +364,12 @@ public function testCanChangeDisplayName() { } }); - $user = new User('foo', $backend, $this->dispatcher); + $config = $this->createMock(IConfig::class); + $config->method('getSystemValueBool') + ->with('allow_user_to_change_display_name') + ->willReturn(true); + + $user = new User('foo', $backend, $this->dispatcher, null, $config); $this->assertTrue($user->canChangeDisplayName()); } @@ -534,6 +539,12 @@ public function testDeleteHooks($result, $expectedHooks) { $config->method('getSystemValue') ->willReturnArgument(1); + $config->method('getSystemValueString') + ->willReturnArgument(1); + $config->method('getSystemValueBool') + ->willReturnArgument(1); + $config->method('getSystemValueInt') + ->willReturnArgument(1); if ($result) { $config->expects($this->once())