Use typed version of IConfig::getSystemValue as much as possible

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
pull/37596/head
Côme Chilliet 1 year ago
parent 5063b76c8a
commit 426c0341ff
No known key found for this signature in database
GPG Key ID: A3E2F658B28C760A

@ -569,7 +569,7 @@ class OC {
self::sendSameSiteCookies();
// Debug mode gets access to the resources without strict cookie
// due to the fact that the SabreDAV browser also lives there.
if (!$config->getSystemValue('debug', false)) {
if (!$config->getSystemValueBool('debug', false)) {
http_response_code(\OCP\AppFramework\Http::STATUS_SERVICE_UNAVAILABLE);
exit();
}
@ -672,7 +672,7 @@ class OC {
\OCP\Server::get(\Psr\Log\LoggerInterface::class),
);
$exceptionHandler = [$errorHandler, 'onException'];
if ($config->getSystemValue('debug', false)) {
if ($config->getSystemValueBool('debug', false)) {
set_error_handler([$errorHandler, 'onAll'], E_ALL);
if (\OC::$CLI) {
$exceptionHandler = ['OC_Template', 'printExceptionErrorPage'];
@ -733,7 +733,7 @@ class OC {
echo('Writing to database failed');
}
exit(1);
} elseif (self::$CLI && $config->getSystemValue('installed', false)) {
} elseif (self::$CLI && $config->getSystemValueBool('installed', false)) {
$config->deleteAppValue('core', 'cronErrors');
}
}
@ -803,7 +803,7 @@ class OC {
*/
if (!OC::$CLI
&& !Server::get(\OC\Security\TrustedDomainHelper::class)->isTrustedDomain($host)
&& $config->getSystemValue('installed', false)
&& $config->getSystemValueBool('installed', false)
) {
// Allow access to CSS resources
$isScssRequest = false;

@ -62,10 +62,10 @@ abstract class Fetcher {
protected $fileName;
/** @var string */
protected $endpointName;
/** @var string */
protected $version;
/** @var string */
protected $channel;
/** @var ?string */
protected $version = null;
/** @var ?string */
protected $channel = null;
public function __construct(Factory $appDataFactory,
IClientService $clientService,
@ -149,7 +149,7 @@ abstract class Fetcher {
*/
public function get($allowUnstable = false) {
$appstoreenabled = $this->config->getSystemValueBool('appstoreenabled', true);
$internetavailable = $this->config->getSystemValue('has_internet_connection', true);
$internetavailable = $this->config->getSystemValueBool('has_internet_connection', true);
if (!$appstoreenabled || !$internetavailable) {
return [];
@ -218,7 +218,7 @@ abstract class Fetcher {
*/
protected function getVersion() {
if ($this->version === null) {
$this->version = $this->config->getSystemValue('version', '0.0.0');
$this->version = $this->config->getSystemValueString('version', '0.0.0');
}
return $this->version;
}
@ -251,6 +251,6 @@ abstract class Fetcher {
}
protected function getEndpoint(): string {
return $this->config->getSystemValue('appstoreurl', 'https://apps.nextcloud.com/api/v1') . '/' . $this->endpointName;
return $this->config->getSystemValueString('appstoreurl', 'https://apps.nextcloud.com/api/v1') . '/' . $this->endpointName;
}
}

@ -56,7 +56,7 @@ class Platform {
}
public function getDatabase(): string {
$dbType = $this->config->getSystemValue('dbtype', 'sqlite');
$dbType = $this->config->getSystemValueString('dbtype', 'sqlite');
if ($dbType === 'sqlite3') {
$dbType = 'sqlite';
}

@ -624,7 +624,7 @@ class Request implements \ArrayAccess, \Countable, IRequest {
* @return bool
*/
private function isOverwriteCondition(string $type = ''): bool {
$regex = '/' . $this->config->getSystemValue('overwritecondaddr', '') . '/';
$regex = '/' . $this->config->getSystemValueString('overwritecondaddr', '') . '/';
$remoteAddr = isset($this->server['REMOTE_ADDR']) ? $this->server['REMOTE_ADDR'] : '';
return $regex === '//' || preg_match($regex, $remoteAddr) === 1
|| $type !== 'protocol';
@ -636,9 +636,9 @@ class Request implements \ArrayAccess, \Countable, IRequest {
* @return string Server protocol (http or https)
*/
public function getServerProtocol(): string {
if ($this->config->getSystemValue('overwriteprotocol') !== ''
if ($this->config->getSystemValueString('overwriteprotocol') !== ''
&& $this->isOverwriteCondition('protocol')) {
return $this->config->getSystemValue('overwriteprotocol');
return $this->config->getSystemValueString('overwriteprotocol');
}
if ($this->fromTrustedProxy() && isset($this->server['HTTP_X_FORWARDED_PROTO'])) {
@ -696,7 +696,7 @@ class Request implements \ArrayAccess, \Countable, IRequest {
*/
public function getRequestUri(): string {
$uri = isset($this->server['REQUEST_URI']) ? $this->server['REQUEST_URI'] : '';
if ($this->config->getSystemValue('overwritewebroot') !== '' && $this->isOverwriteCondition()) {
if ($this->config->getSystemValueString('overwritewebroot') !== '' && $this->isOverwriteCondition()) {
$uri = $this->getScriptName() . substr($uri, \strlen($this->server['SCRIPT_NAME']));
}
return $uri;
@ -764,7 +764,7 @@ class Request implements \ArrayAccess, \Countable, IRequest {
*/
public function getScriptName(): string {
$name = $this->server['SCRIPT_NAME'];
$overwriteWebRoot = $this->config->getSystemValue('overwritewebroot');
$overwriteWebRoot = $this->config->getSystemValueString('overwritewebroot');
if ($overwriteWebRoot !== '' && $this->isOverwriteCondition()) {
// FIXME: This code is untestable due to __DIR__, also that hardcoded path is really dangerous
$serverRoot = str_replace('\\', '/', substr(__DIR__, 0, -\strlen('lib/private/appframework/http/')));
@ -859,8 +859,8 @@ class Request implements \ArrayAccess, \Countable, IRequest {
* isn't met
*/
private function getOverwriteHost() {
if ($this->config->getSystemValue('overwritehost') !== '' && $this->isOverwriteCondition()) {
return $this->config->getSystemValue('overwritehost');
if ($this->config->getSystemValueString('overwritehost') !== '' && $this->isOverwriteCondition()) {
return $this->config->getSystemValueString('overwritehost');
}
return null;
}

@ -41,7 +41,7 @@ class FinishRememberedLoginCommand extends ALoginCommand {
}
public function process(LoginData $loginData): LoginResult {
if ($loginData->isRememberLogin() && $this->config->getSystemValue('auto_logout', false) === false) {
if ($loginData->isRememberLogin() && !$this->config->getSystemValueBool('auto_logout', false)) {
$this->userSession->createRememberMeToken($loginData->getUser());
}

@ -265,10 +265,10 @@ class PublicKeyTokenProvider implements IProvider {
public function invalidateOldTokens() {
$this->cache->clear();
$olderThan = $this->time->getTime() - (int) $this->config->getSystemValue('session_lifetime', 60 * 60 * 24);
$olderThan = $this->time->getTime() - $this->config->getSystemValueInt('session_lifetime', 60 * 60 * 24);
$this->logger->debug('Invalidating session tokens older than ' . date('c', $olderThan), ['app' => 'cron']);
$this->mapper->invalidateOld($olderThan, IToken::DO_NOT_REMEMBER);
$rememberThreshold = $this->time->getTime() - (int) $this->config->getSystemValue('remember_login_cookie_lifetime', 60 * 60 * 24 * 15);
$rememberThreshold = $this->time->getTime() - $this->config->getSystemValueInt('remember_login_cookie_lifetime', 60 * 60 * 24 * 15);
$this->logger->debug('Invalidating remembered session tokens older than ' . date('c', $rememberThreshold), ['app' => 'cron']);
$this->mapper->invalidateOld($rememberThreshold, IToken::REMEMBER);
}
@ -364,7 +364,7 @@ class PublicKeyTokenProvider implements IProvider {
}
private function encrypt(string $plaintext, string $token): string {
$secret = $this->config->getSystemValue('secret');
$secret = $this->config->getSystemValueString('secret');
return $this->crypto->encrypt($plaintext, $token . $secret);
}
@ -372,7 +372,7 @@ class PublicKeyTokenProvider implements IProvider {
* @throws InvalidTokenException
*/
private function decrypt(string $cipherText, string $token): string {
$secret = $this->config->getSystemValue('secret');
$secret = $this->config->getSystemValueString('secret');
try {
return $this->crypto->decrypt($cipherText, $token . $secret);
} catch (\Exception $ex) {
@ -402,7 +402,7 @@ class PublicKeyTokenProvider implements IProvider {
}
private function hashToken(string $token): string {
$secret = $this->config->getSystemValue('secret');
$secret = $this->config->getSystemValueString('secret');
return hash('sha512', $token . $secret);
}

@ -63,7 +63,7 @@ class LookupPlugin implements ISearchPlugin {
}
public function search($search, $limit, $offset, ISearchResult $searchResult) {
$isGlobalScaleEnabled = $this->config->getSystemValue('gs.enabled', false);
$isGlobalScaleEnabled = $this->config->getSystemValueBool('gs.enabled', false);
$isLookupServerEnabled = $this->config->getAppValue('files_sharing', 'lookupServerEnabled', 'yes') === 'yes';
$hasInternetConnection = $this->config->getSystemValueBool('has_internet_connection', true);
@ -72,7 +72,7 @@ class LookupPlugin implements ISearchPlugin {
return false;
}
$lookupServerUrl = $this->config->getSystemValue('lookup_server', 'https://lookup.nextcloud.com');
$lookupServerUrl = $this->config->getSystemValueString('lookup_server', 'https://lookup.nextcloud.com');
if (empty($lookupServerUrl)) {
return false;
}

@ -112,7 +112,7 @@ class Application {
try {
require_once __DIR__ . '/../../../core/register_command.php';
if ($this->config->getSystemValue('installed', false)) {
if ($this->config->getSystemValueBool('installed', false)) {
if (\OCP\Util::needUpgrade()) {
throw new NeedsUpdateException();
} elseif ($this->config->getSystemValueBool('maintenance')) {

@ -178,7 +178,7 @@ class Migrator {
}
protected function getFilterExpression() {
return '/^' . preg_quote($this->config->getSystemValue('dbtableprefix', 'oc_')) . '/';
return '/^' . preg_quote($this->config->getSystemValueString('dbtableprefix', 'oc_')) . '/';
}
protected function emit(string $sql, int $step, int $max): void {

@ -216,6 +216,6 @@ class OracleMigrator extends Migrator {
}
protected function getFilterExpression() {
return '/^"' . preg_quote($this->config->getSystemValue('dbtableprefix', 'oc_')) . '/';
return '/^"' . preg_quote($this->config->getSystemValueString('dbtableprefix', 'oc_')) . '/';
}
}

@ -53,7 +53,7 @@ class PgSqlTools {
$databaseName = $conn->getDatabase();
$conn->getConfiguration()->setSchemaAssetsFilter(function ($asset) {
/** @var string|AbstractAsset $asset */
$filterExpression = '/^' . preg_quote($this->config->getSystemValue('dbtableprefix', 'oc_')) . '/';
$filterExpression = '/^' . preg_quote($this->config->getSystemValueString('dbtableprefix', 'oc_')) . '/';
if ($asset instanceof AbstractAsset) {
return preg_match($filterExpression, $asset->getName()) !== false;
}

@ -237,7 +237,7 @@ class Storage implements IStorage {
if (!array_key_exists('uid', $data) || $data['uid'] !== $uid) {
// If the migration is done we error out
$versionFromBeforeUpdate = $this->config->getSystemValue('version', '0.0.0.0');
$versionFromBeforeUpdate = $this->config->getSystemValueString('version', '0.0.0.0');
if (version_compare($versionFromBeforeUpdate, '20.0.0.1', '<=')) {
return $data['key'];
}
@ -272,7 +272,7 @@ class Storage implements IStorage {
$data = $this->view->file_get_contents($path);
// Version <20.0.0.1 doesn't have this
$versionFromBeforeUpdate = $this->config->getSystemValue('version', '0.0.0.0');
$versionFromBeforeUpdate = $this->config->getSystemValueString('version', '0.0.0.0');
if (version_compare($versionFromBeforeUpdate, '20.0.0.1', '<=')) {
$key = [
'key' => base64_encode($data),
@ -335,7 +335,7 @@ class Storage implements IStorage {
private function setKey($path, $key) {
$this->keySetPreparation(dirname($path));
$versionFromBeforeUpdate = $this->config->getSystemValue('version', '0.0.0.0');
$versionFromBeforeUpdate = $this->config->getSystemValueString('version', '0.0.0.0');
if (version_compare($versionFromBeforeUpdate, '20.0.0.1', '<=')) {
// Only store old format if this happens during the migration.
// TODO: Remove for 21

@ -73,7 +73,7 @@ class Manager implements IManager {
* @return bool true if enabled, false if not
*/
public function isEnabled() {
$installed = $this->config->getSystemValue('installed', false);
$installed = $this->config->getSystemValueBool('installed', false);
if (!$installed) {
return false;
}

@ -70,7 +70,7 @@ class Util {
protected $config;
/** @var array paths excluded from encryption */
protected $excludedPaths;
protected array $excludedPaths = [];
protected IGroupManager $groupManager;
protected IUserManager $userManager;
@ -94,7 +94,7 @@ class Util {
$this->config = $config;
$this->excludedPaths[] = 'files_encryption';
$this->excludedPaths[] = 'appdata_' . $config->getSystemValue('instanceid', null);
$this->excludedPaths[] = 'appdata_' . $config->getSystemValueString('instanceid');
$this->excludedPaths[] = 'files_external';
}

@ -91,7 +91,7 @@ class Scanner extends BasicEmitter implements IScanner {
$this->storage = $storage;
$this->storageId = $this->storage->getId();
$this->cache = $storage->getCache();
$this->cacheActive = !\OC::$server->getConfig()->getSystemValue('filesystem_cache_readonly', false);
$this->cacheActive = !\OC::$server->getConfig()->getSystemValueBool('filesystem_cache_readonly', false);
$this->lockingProvider = \OC::$server->getLockingProvider();
}
@ -219,7 +219,7 @@ class Scanner extends BasicEmitter implements IScanner {
$newData['parent'] = $parentId;
$data['fileid'] = $this->addToCache($file, $newData, $fileId);
}
$data['oldSize'] = ($cacheData && isset($cacheData['size'])) ? $cacheData['size'] : 0;
if ($cacheData && isset($cacheData['encrypted'])) {

@ -52,7 +52,7 @@ class CacheMountProvider implements IMountProvider {
* @return \OCP\Files\Mount\IMountPoint[]
*/
public function getMountsForUser(IUser $user, IStorageFactory $loader) {
$cacheBaseDir = $this->config->getSystemValue('cache_path', '');
$cacheBaseDir = $this->config->getSystemValueString('cache_path', '');
if ($cacheBaseDir !== '') {
$cacheDir = rtrim($cacheBaseDir, '/') . '/' . $user->getUID();
if (!file_exists($cacheDir)) {

@ -834,7 +834,7 @@ abstract class Common implements Storage, ILockingStorage, IWriteStreamStorage {
private function getLockLogger(): ?LoggerInterface {
if (is_null($this->shouldLogLocks)) {
$this->shouldLogLocks = \OC::$server->getConfig()->getSystemValue('filelocking.debug', false);
$this->shouldLogLocks = \OC::$server->getConfig()->getSystemValueBool('filelocking.debug', false);
$this->logger = $this->shouldLogLocks ? \OC::$server->get(LoggerInterface::class) : null;
}
return $this->logger;

@ -145,7 +145,7 @@ class DAV extends Common {
$settings['authType'] = $this->authType;
}
$proxy = \OC::$server->getConfig()->getSystemValue('proxy', '');
$proxy = \OC::$server->getConfig()->getSystemValueString('proxy', '');
if ($proxy !== '') {
$settings['proxy'] = $proxy;
}

@ -93,7 +93,7 @@ class Local extends \OC\Files\Storage\Common {
$this->defUMask = $this->config->getSystemValue('localstorage.umask', 0022);
// support Write-Once-Read-Many file systems
$this->unlinkOnTruncate = $this->config->getSystemValue('localstorage.unlink_on_truncate', false);
$this->unlinkOnTruncate = $this->config->getSystemValueBool('localstorage.unlink_on_truncate', false);
}
public function __destruct() {
@ -486,7 +486,7 @@ class Local extends \OC\Files\Storage\Common {
$fullPath = $this->datadir . $path;
$currentPath = $path;
$allowSymlinks = $this->config->getSystemValue('localstorage.allowsymlinks', false);
$allowSymlinks = $this->config->getSystemValueBool('localstorage.allowsymlinks', false);
if ($allowSymlinks || $currentPath === '') {
return $fullPath;
}

@ -268,8 +268,8 @@ class TemplateManager implements ITemplateManager {
$defaultSkeletonDirectory = \OC::$SERVERROOT . '/core/skeleton';
$defaultTemplateDirectory = \OC::$SERVERROOT . '/core/skeleton/Templates';
$skeletonPath = $this->config->getSystemValue('skeletondirectory', $defaultSkeletonDirectory);
$skeletonTemplatePath = $this->config->getSystemValue('templatedirectory', $defaultTemplateDirectory);
$skeletonPath = $this->config->getSystemValueString('skeletondirectory', $defaultSkeletonDirectory);
$skeletonTemplatePath = $this->config->getSystemValueString('templatedirectory', $defaultTemplateDirectory);
$isDefaultSkeleton = $skeletonPath === $defaultSkeletonDirectory;
$isDefaultTemplates = $skeletonTemplatePath === $defaultTemplateDirectory;
$userLang = $this->l10nFactory->getUserLanguage($this->userManager->get($this->userId));

@ -44,8 +44,7 @@ class Config implements \OCP\GlobalScale\IConfig {
* @return bool
*/
public function isGlobalScaleEnabled() {
$enabled = $this->config->getSystemValue('gs.enabled', false);
return $enabled !== false;
return $this->config->getSystemValueBool('gs.enabled', false);
}
/**
@ -61,7 +60,7 @@ class Config implements \OCP\GlobalScale\IConfig {
return false;
}
$enabled = $this->config->getSystemValue('gs.federation', 'internal');
$enabled = $this->config->getSystemValueString('gs.federation', 'internal');
return $enabled === 'internal';
}

@ -122,7 +122,7 @@ class Client implements IClient {
// If the instance is not yet setup we need to use the static path as
// $this->certificateManager->getAbsoluteBundlePath() tries to instantiate
// a view
if ($this->config->getSystemValue('installed', false) === false) {
if (!$this->config->getSystemValueBool('installed', false)) {
return \OC::$SERVERROOT . '/resources/config/ca-bundle.crt';
}
@ -145,14 +145,14 @@ class Client implements IClient {
*
*/
private function getProxyUri(): ?array {
$proxyHost = $this->config->getSystemValue('proxy', '');
$proxyHost = $this->config->getSystemValueString('proxy', '');
if ($proxyHost === '' || $proxyHost === null) {
if ($proxyHost === '') {
return null;
}
$proxyUserPwd = $this->config->getSystemValue('proxyuserpwd', '');
if ($proxyUserPwd !== '' && $proxyUserPwd !== null) {
$proxyUserPwd = $this->config->getSystemValueString('proxyuserpwd', '');
if ($proxyUserPwd !== '') {
$proxyHost = $proxyUserPwd . '@' . $proxyHost;
}

@ -116,9 +116,9 @@ class Checker {
*/
$isIntegrityCheckDisabled = false;
if ($this->config !== null) {
$isIntegrityCheckDisabled = $this->config->getSystemValue('integrity.check.disabled', false);
$isIntegrityCheckDisabled = $this->config->getSystemValueBool('integrity.check.disabled', false);
}
if ($isIntegrityCheckDisabled === true) {
if ($isIntegrityCheckDisabled) {
return false;
}

@ -51,7 +51,7 @@ class ExcludeFoldersByPathFilterIterator extends \RecursiveFilterIterator {
rtrim($root . '/updater', '/'),
rtrim($root . '/_oc_upgrade', '/'),
];
$customDataDir = \OC::$server->getConfig()->getSystemValue('datadirectory', '');
$customDataDir = \OC::$server->getConfig()->getSystemValueString('datadirectory', '');
if ($customDataDir !== '') {
$excludedFolders[] = rtrim($customDataDir, '/');
}

@ -195,7 +195,7 @@ class Factory implements IFactory {
*
* @link https://github.com/owncloud/core/issues/21955
*/
if ($this->config->getSystemValue('installed', false)) {
if ($this->config->getSystemValueBool('installed', false)) {
$userId = !is_null($this->userSession->getUser()) ? $this->userSession->getUser()->getUID() : null;
if (!is_null($userId)) {
$userLang = $this->config->getUserValue($userId, 'core', 'lang', null);
@ -247,7 +247,7 @@ class Factory implements IFactory {
}
// Step 3.1: Check if Nextcloud is already installed before we try to access user info
if (!$this->config->getSystemValue('installed', false)) {
if (!$this->config->getSystemValueBool('installed', false)) {
return 'en';
}
// Step 3.2: Check the current user (if any) for their preferred language
@ -282,7 +282,7 @@ class Factory implements IFactory {
return $forceLocale;
}
if ($this->config->getSystemValue('installed', false)) {
if ($this->config->getSystemValueBool('installed', false)) {
$userId = null !== $this->userSession->getUser() ? $this->userSession->getUser()->getUID() : null;
$userLocale = null;
if (null !== $userId) {
@ -366,7 +366,7 @@ class Factory implements IFactory {
}
// merge with translations from theme
$theme = $this->config->getSystemValue('theme');
$theme = $this->config->getSystemValueString('theme');
if (!empty($theme)) {
$themeDir = $this->serverRoot . '/themes/' . $theme . substr($dir, strlen($this->serverRoot));
@ -452,7 +452,7 @@ class Factory implements IFactory {
}
}
return $this->config->getSystemValue('default_language', 'en');
return $this->config->getSystemValueString('default_language', 'en');
}
/**
@ -576,7 +576,7 @@ class Factory implements IFactory {
}
// merge with translations from theme
$theme = $this->config->getSystemValue('theme');
$theme = $this->config->getSystemValueString('theme');
if (!empty($theme)) {
$transFile = $this->serverRoot . '/themes/' . $theme . substr($transFile, strlen($this->serverRoot));
if (file_exists($transFile)) {

@ -93,7 +93,7 @@ class LanguageIterator implements ILanguageIterator {
$this->next();
// no break
case 4:
return $this->config->getSystemValue('default_language', 'en');
return $this->config->getSystemValueString('default_language', 'en');
/** @noinspection PhpMissingBreakStatementInspection */
case 5:
$defaultLang = $this->config->getSystemValue('default_language', 'en');

@ -39,7 +39,7 @@ class Rotate extends \OCP\BackgroundJob\Job {
$systemConfig = \OC::$server->getSystemConfig();
$this->filePath = $systemConfig->getValue('logfile', $systemConfig->getValue('datadirectory', \OC::$SERVERROOT . '/data') . '/nextcloud.log');
$this->maxSize = \OC::$server->getConfig()->getSystemValue('log_rotate_size', 100 * 1024 * 1024);
$this->maxSize = \OC::$server->getConfig()->getSystemValueInt('log_rotate_size', 100 * 1024 * 1024);
if ($this->shouldRotateBySize()) {
$rotatedFile = $this->rotate();
$msg = 'Log file "'.$this->filePath.'" was over '.$this->maxSize.' bytes, moved to "'.$rotatedFile.'"';

@ -57,7 +57,6 @@ use Symfony\Component\Mailer\Transport\SendmailTransport;
use Symfony\Component\Mailer\Transport\Smtp\EsmtpTransport;
use Symfony\Component\Mailer\Transport\Smtp\Stream\SocketStream;
use Symfony\Component\Mime\Email;
use Symfony\Component\Mime\Exception\InvalidArgumentException;
use Symfony\Component\Mime\Exception\RfcComplianceException;
/**
@ -110,7 +109,7 @@ class Mailer implements IMailer {
* @return Message
*/
public function createMessage(): Message {
$plainTextOnly = $this->config->getSystemValue('mail_send_plaintext_only', false);
$plainTextOnly = $this->config->getSystemValueBool('mail_send_plaintext_only', false);
return new Message(new Email(), $plainTextOnly);
}
@ -144,7 +143,7 @@ class Mailer implements IMailer {
* @since 12.0.0
*/
public function createEMailTemplate(string $emailId, array $data = []): IEMailTemplate {
$class = $this->config->getSystemValue('mail_template_class', '');
$class = $this->config->getSystemValueString('mail_template_class', '');
if ($class !== '' && class_exists($class) && is_a($class, EMailTemplate::class, true)) {
return new $class(
@ -176,10 +175,10 @@ class Mailer implements IMailer {
* @return string[] $failedRecipients
*/
public function send(IMessage $message): array {
$debugMode = $this->config->getSystemValue('mail_smtpdebug', false);
$debugMode = $this->config->getSystemValueBool('mail_smtpdebug', false);
if (!($message instanceof Message)) {
throw new InvalidArgumentException('Object not of type ' . Message::class);
throw new \InvalidArgumentException('Object not of type ' . Message::class);
}
if (empty($message->getFrom())) {
@ -192,7 +191,7 @@ class Mailer implements IMailer {
try {
$message->setRecipients();
} catch (InvalidArgumentException|RfcComplianceException $e) {
} catch (\InvalidArgumentException|RfcComplianceException $e) {
$logMessage = sprintf(
'Could not send mail to "%s" with subject "%s" as validation for address failed',
print_r(array_merge($message->getTo(), $message->getCc(), $message->getBcc()), true),
@ -267,7 +266,7 @@ class Mailer implements IMailer {
$transport = null;
switch ($this->config->getSystemValue('mail_smtpmode', 'smtp')) {
switch ($this->config->getSystemValueString('mail_smtpmode', 'smtp')) {
case 'sendmail':
$transport = $this->getSendMailInstance();
break;
@ -294,7 +293,7 @@ class Mailer implements IMailer {
$mailSmtpsecure = ($this->config->getSystemValue('mail_smtpsecure', null) === 'ssl') ? true : null;
$transport = new EsmtpTransport(
$this->config->getSystemValue('mail_smtphost', '127.0.0.1'),
(int)$this->config->getSystemValue('mail_smtpport', 25),
$this->config->getSystemValueInt('mail_smtpport', 25),
$mailSmtpsecure,
null,
$this->logger
@ -304,7 +303,7 @@ class Mailer implements IMailer {
/** @psalm-suppress InternalMethod */
$stream->setTimeout($this->config->getSystemValue('mail_smtptimeout', 10));
if ($this->config->getSystemValue('mail_smtpauth', false)) {
if ($this->config->getSystemValueBool('mail_smtpauth', false)) {
$transport->setUsername($this->config->getSystemValue('mail_smtpname', ''));
$transport->setPassword($this->config->getSystemValue('mail_smtppassword', ''));
}
@ -338,7 +337,7 @@ class Mailer implements IMailer {
* @return SendmailTransport
*/
protected function getSendMailInstance(): SendmailTransport {
switch ($this->config->getSystemValue('mail_smtpmode', 'smtp')) {
switch ($this->config->getSystemValueString('mail_smtpmode', 'smtp')) {
case 'qmail':
$binaryPath = '/var/qmail/bin/sendmail';
break;
@ -351,7 +350,7 @@ class Mailer implements IMailer {
break;
}
switch ($this->config->getSystemValue('mail_sendmailmode', 'smtp')) {
switch ($this->config->getSystemValueString('mail_sendmailmode', 'smtp')) {
case 'pipe':
$binaryParam = ' -t';
break;

@ -189,7 +189,7 @@ class NavigationManager implements INavigationManager {
$this->init = true;
$l = $this->l10nFac->get('lib');
if ($this->config->getSystemValue('knowledgebaseenabled', true)) {
if ($this->config->getSystemValueBool('knowledgebaseenabled', true)) {
$this->add([
'type' => 'settings',
'id' => 'help',

@ -61,7 +61,7 @@ class Imaginary extends ProviderV2 {
}
public function getCroppedThumbnail(File $file, int $maxX, int $maxY, bool $crop): ?IImage {
$maxSizeForImages = $this->config->getSystemValue('preview_max_filesize_image', 50);
$maxSizeForImages = $this->config->getSystemValueInt('preview_max_filesize_image', 50);
$size = $file->getSize();
@ -105,7 +105,7 @@ class Imaginary extends ProviderV2 {
default:
$mimeType = 'jpeg';
}
$operations = [];
if ($convert) {

@ -113,7 +113,7 @@ class PreviewManager implements IPreview {
* @return void
*/
public function registerProvider($mimeTypeRegex, \Closure $callable): void {
if (!$this->config->getSystemValue('enable_previews', true)) {
if (!$this->config->getSystemValueBool('enable_previews', true)) {
return;
}

@ -49,7 +49,7 @@ class ClearGeneratedAvatarCache implements IRepairStep {
* Check if this repair step should run
*/
private function shouldRun(): bool {
$versionFromBeforeUpdate = $this->config->getSystemValue('version', '0.0.0.0');
$versionFromBeforeUpdate = $this->config->getSystemValueString('version', '0.0.0.0');
// was added to 25.0.0.10
return version_compare($versionFromBeforeUpdate, '25.0.0.10', '<=');

@ -74,7 +74,7 @@ class Collation implements IRepairStep {
return;
}
$characterSet = $this->config->getSystemValue('mysql.utf8mb4', false) ? 'utf8mb4' : 'utf8';
$characterSet = $this->config->getSystemValueBool('mysql.utf8mb4', false) ? 'utf8mb4' : 'utf8';
$tables = $this->getAllNonUTF8BinTables($this->connection);
foreach ($tables as $table) {
@ -112,8 +112,8 @@ class Collation implements IRepairStep {
* @return string[]
*/
protected function getAllNonUTF8BinTables(IDBConnection $connection) {
$dbName = $this->config->getSystemValue("dbname");
$characterSet = $this->config->getSystemValue('mysql.utf8mb4', false) ? 'utf8mb4' : 'utf8';
$dbName = $this->config->getSystemValueString("dbname");
$characterSet = $this->config->getSystemValueBool('mysql.utf8mb4', false) ? 'utf8mb4' : 'utf8';
// fetch tables by columns
$statement = $connection->executeQuery(

@ -43,9 +43,9 @@ class MoveUpdaterStepFile implements IRepairStep {
public function run(IOutput $output) {
$updateDir = $this->config->getSystemValue('updatedirectory', null) ?? $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data');
$instanceId = $this->config->getSystemValue('instanceid', null);
$instanceId = $this->config->getSystemValueString('instanceid');
if (!is_string($instanceId) || empty($instanceId)) {
if (empty($instanceId)) {
return;
}

@ -96,7 +96,7 @@ class CleanupCardDAVPhotoCache implements IRepairStep {
private function shouldRun(): bool {
return version_compare(
$this->config->getSystemValue('version', '0.0.0.0'),
$this->config->getSystemValueString('version', '0.0.0.0'),
'16.0.0.0',
'<='
);

@ -48,7 +48,7 @@ class ClearCollectionsAccessCache implements IRepairStep {
}
private function shouldRun(): bool {
$versionFromBeforeUpdate = $this->config->getSystemValue('version', '0.0.0.0');
$versionFromBeforeUpdate = $this->config->getSystemValueString('version', '0.0.0.0');
return version_compare($versionFromBeforeUpdate, '17.0.0.3', '<=');
}

@ -47,7 +47,7 @@ class ResetGeneratedAvatarFlag implements IRepairStep {
}
private function shouldRun(): bool {
$versionFromBeforeUpdate = $this->config->getSystemValue('version', '0.0.0.0');
$versionFromBeforeUpdate = $this->config->getSystemValueString('version', '0.0.0.0');
return version_compare($versionFromBeforeUpdate, '18.0.0.5', '<=');
}

@ -48,7 +48,7 @@ class EncryptionLegacyCipher implements IRepairStep {
}
private function shouldRun(): bool {
$versionFromBeforeUpdate = $this->config->getSystemValue('version', '0.0.0.0');
$versionFromBeforeUpdate = $this->config->getSystemValueString('version', '0.0.0.0');
return version_compare($versionFromBeforeUpdate, '20.0.0.0', '<=');
}

@ -48,7 +48,7 @@ class EncryptionMigration implements IRepairStep {
}
private function shouldRun(): bool {
$versionFromBeforeUpdate = $this->config->getSystemValue('version', '0.0.0.0');
$versionFromBeforeUpdate = $this->config->getSystemValueString('version', '0.0.0.0');
return version_compare($versionFromBeforeUpdate, '20.0.0.1', '<=');
}

@ -44,7 +44,7 @@ class AddCheckForUserCertificatesJob implements IRepairStep {
}
private function shouldRun() {
$versionFromBeforeUpdate = $this->config->getSystemValue('version', '0.0.0.0');
$versionFromBeforeUpdate = $this->config->getSystemValueString('version', '0.0.0.0');
// was added to 21.0.0.2
return version_compare($versionFromBeforeUpdate, '21.0.0.2', '<');

@ -46,7 +46,7 @@ class LookupServerSendCheck implements IRepairStep {
}
private function shouldRun(): bool {
$versionFromBeforeUpdate = $this->config->getSystemValue('version', '0.0.0.0');
$versionFromBeforeUpdate = $this->config->getSystemValueString('version', '0.0.0.0');
// was added to 22.0.0.3
return (version_compare($versionFromBeforeUpdate, '22.0.0.3', '<') && version_compare($versionFromBeforeUpdate, '22.0.0.0', '>='))

@ -42,8 +42,8 @@ class AddMissingSecretJob implements IRepairStep {
}
public function run(IOutput $output): void {
$passwordSalt = $this->config->getSystemValue('passwordsalt', null);
if ($passwordSalt === null || $passwordSalt === '') {
$passwordSalt = $this->config->getSystemValueString('passwordsalt', '');
if ($passwordSalt === '') {
try {
$this->config->setSystemValue('passwordsalt', $this->random->generate(30));
} catch (HintException $e) {
@ -51,8 +51,8 @@ class AddMissingSecretJob implements IRepairStep {
}
}
$secret = $this->config->getSystemValue('secret', null);
if ($secret === null || $secret === '') {
$secret = $this->config->getSystemValueString('secret', '');
if ($secret === '') {
try {
$this->config->setSystemValue('secret', $this->random->generate(48));
} catch (HintException $e) {

@ -59,7 +59,7 @@ class MoveAvatars implements IRepairStep {
$output->info('Repair step already executed');
return;
}
if ($this->config->getSystemValue('enable_avatars', true) === false) {
if (!$this->config->getSystemValueBool('enable_avatars', true)) {
$output->info('Avatars are disabled');
} else {
$output->info('Add background job');

@ -79,7 +79,7 @@ class SaveAccountsTableData implements IRepairStep {
}
// oc_persistent_locks will be removed later on anyways so we can just drop and ignore any foreign key constraints here
$tableName = $this->config->getSystemValue('dbtableprefix', 'oc_') . 'persistent_locks';
$tableName = $this->config->getSystemValueString('dbtableprefix', 'oc_') . 'persistent_locks';
$schema = $this->db->createSchema();
$table = $schema->getTable($tableName);
foreach ($table->getForeignKeys() as $foreignKey) {
@ -99,7 +99,7 @@ class SaveAccountsTableData implements IRepairStep {
*/
protected function shouldRun() {
$schema = $this->db->createSchema();
$prefix = $this->config->getSystemValue('dbtableprefix', 'oc_');
$prefix = $this->config->getSystemValueString('dbtableprefix', 'oc_');
$tableName = $prefix . 'accounts';
if (!$schema->hasTable($tableName)) {

@ -56,7 +56,7 @@ class UpdateLanguageCodes implements IRepairStep {
* {@inheritdoc}
*/
public function run(IOutput $output) {
$versionFromBeforeUpdate = $this->config->getSystemValue('version', '0.0.0');
$versionFromBeforeUpdate = $this->config->getSystemValueString('version', '0.0.0');
if (version_compare($versionFromBeforeUpdate, '12.0.0.13', '>')) {
return;

@ -71,7 +71,7 @@ class RemoveLinkShares implements IRepairStep {
}
private function shouldRun(): bool {
$versionFromBeforeUpdate = $this->config->getSystemValue('version', '0.0.0');
$versionFromBeforeUpdate = $this->config->getSystemValueString('version', '0.0.0');
if (version_compare($versionFromBeforeUpdate, '14.0.11', '<')) {
return true;

@ -125,7 +125,7 @@ class RepairDavShares implements IRepairStep {
* @inheritDoc
*/
public function run(IOutput $output) {
$versionFromBeforeUpdate = $this->config->getSystemValue('version', '0.0.0');
$versionFromBeforeUpdate = $this->config->getSystemValueString('version', '0.0.0');
if (version_compare($versionFromBeforeUpdate, '20.0.8', '<')
&& $this->repairUnencodedGroupShares()
) {

@ -110,7 +110,7 @@ class RepairInvalidShares implements IRepairStep {
}
public function run(IOutput $out) {
$ocVersionFromBeforeUpdate = $this->config->getSystemValue('version', '0.0.0');
$ocVersionFromBeforeUpdate = $this->config->getSystemValueString('version', '0.0.0');
if (version_compare($ocVersionFromBeforeUpdate, '12.0.0.11', '<')) {
$this->adjustFileSharePermissions($out);
}

@ -234,7 +234,7 @@ class RepairMimeTypes implements IRepairStep {
* Fix mime types
*/
public function run(IOutput $out) {
$ocVersionFromBeforeUpdate = $this->config->getSystemValue('version', '0.0.0');
$ocVersionFromBeforeUpdate = $this->config->getSystemValueString('version', '0.0.0');
// NOTE TO DEVELOPERS: when adding new mime types, please make sure to
// add a version comparison to avoid doing it every time

@ -51,7 +51,7 @@ class Capabilities implements IPublicCapability, IInitialStateExcludedCapability
}
public function getCapabilities(): array {
if (version_compare(\OC::$server->getConfig()->getSystemValue('version', '0.0.0.0'), '12.0.0.0', '<')) {
if (version_compare(\OC::$server->getConfig()->getSystemValueString('version', '0.0.0.0'), '12.0.0.0', '<')) {
return [];
}

@ -112,7 +112,7 @@ class Throttler implements IThrottler {
string $ip,
array $metadata = []): void {
// No need to log if the bruteforce protection is disabled
if ($this->config->getSystemValue('auth.bruteforce.protection.enabled', true) === false) {
if (!$this->config->getSystemValueBool('auth.bruteforce.protection.enabled', true)) {
return;
}
@ -151,7 +151,7 @@ class Throttler implements IThrottler {
* @return bool
*/
private function isIPWhitelisted(string $ip): bool {
if ($this->config->getSystemValue('auth.bruteforce.protection.enabled', true) === false) {
if (!$this->config->getSystemValueBool('auth.bruteforce.protection.enabled', true)) {
return true;
}

@ -67,7 +67,7 @@ class CertificateManager implements ICertificateManager {
* @return \OCP\ICertificate[]
*/
public function listCertificates(): array {
if (!$this->config->getSystemValue('installed', false)) {
if (!$this->config->getSystemValueBool('installed', false)) {
return [];
}
@ -93,7 +93,7 @@ class CertificateManager implements ICertificateManager {
}
private function hasCertificates(): bool {
if (!$this->config->getSystemValue('installed', false)) {
if (!$this->config->getSystemValueBool('installed', false)) {
return false;
}

@ -70,7 +70,7 @@ class Crypto implements ICrypto {
*/
public function calculateHMAC(string $message, string $password = ''): string {
if ($password === '') {
$password = $this->config->getSystemValue('secret');
$password = $this->config->getSystemValueString('secret');
}
// Append an "a" behind the password and hash it to prevent reusing the same password as for encryption
@ -92,7 +92,7 @@ class Crypto implements ICrypto {
*/
public function encrypt(string $plaintext, string $password = ''): string {
if ($password === '') {
$password = $this->config->getSystemValue('secret');
$password = $this->config->getSystemValueString('secret');
}
$keyMaterial = hash_hkdf('sha512', $password);
$this->cipher->setPassword(substr($keyMaterial, 0, 32));

@ -209,7 +209,7 @@ class Hasher implements IHasher {
}
// Check if we should use PASSWORD_DEFAULT
if ($this->config->getSystemValue('hashing_default_password', false) === true) {
if ($this->config->getSystemValueBool('hashing_default_password', false)) {
$default = PASSWORD_DEFAULT;
}

@ -82,7 +82,7 @@ class VerificationToken implements IVerificationToken {
}
try {
$decryptedToken = $this->crypto->decrypt($encryptedToken, $passwordPrefix.$this->config->getSystemValue('secret'));
$decryptedToken = $this->crypto->decrypt($encryptedToken, $passwordPrefix.$this->config->getSystemValueString('secret'));
} catch (\Exception $e) {
// Retry with empty secret as a fallback for instances where the secret might not have been set by accident
try {
@ -115,7 +115,7 @@ class VerificationToken implements IVerificationToken {
ISecureRandom::CHAR_UPPER
);
$tokenValue = $this->timeFactory->getTime() .':'. $token;
$encryptedValue = $this->crypto->encrypt($tokenValue, $passwordPrefix . $this->config->getSystemValue('secret'));
$encryptedValue = $this->crypto->encrypt($tokenValue, $passwordPrefix . $this->config->getSystemValueString('secret'));
$this->config->setUserValue($user->getUID(), 'core', $subject, $encryptedValue);
$jobArgs = json_encode([
'userId' => $user->getUID(),

@ -726,7 +726,7 @@ class Server extends ServerContainer implements IServerContainer {
/** @var \OCP\IConfig $config */
$config = $c->get(\OCP\IConfig::class);
if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
if ($config->getSystemValueBool('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
if (!$config->getSystemValueBool('log_query')) {
$v = \OC_App::getAppVersions();
} else {
@ -988,7 +988,7 @@ class Server extends ServerContainer implements IServerContainer {
/** @deprecated 20.0.0 */
$this->registerDeprecatedAlias('IniWrapper', IniGetWrapper::class);
$this->registerService(IBus::class, function (ContainerInterface $c) {
$busClass = $c->get(\OCP\IConfig::class)->getSystemValue('commandbus');
$busClass = $c->get(\OCP\IConfig::class)->getSystemValueString('commandbus');
if ($busClass) {
[$app, $class] = explode('::', $busClass, 2);
if ($c->get(IAppManager::class)->isInstalled($app)) {
@ -1107,8 +1107,8 @@ class Server extends ServerContainer implements IServerContainer {
$this->registerService(ILockingProvider::class, function (ContainerInterface $c) {
$ini = $c->get(IniGetWrapper::class);
$config = $c->get(\OCP\IConfig::class);
$ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time')));
if ($config->getSystemValue('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
$ttl = $config->getSystemValueInt('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time')));
if ($config->getSystemValueBool('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
/** @var \OC\Memcache\Factory $memcacheFactory */
$memcacheFactory = $c->get(ICacheFactory::class);
$memcache = $memcacheFactory->createLocking('lock');
@ -1208,7 +1208,7 @@ class Server extends ServerContainer implements IServerContainer {
$classExists = false;
}
if ($classExists && $c->get(\OCP\IConfig::class)->getSystemValue('installed', false) && $c->get(IAppManager::class)->isInstalled('theming') && $c->getTrustedDomainHelper()->isTrustedDomain($c->getRequest()->getInsecureServerHost())) {
if ($classExists && $c->get(\OCP\IConfig::class)->getSystemValueBool('installed', false) && $c->get(IAppManager::class)->isInstalled('theming') && $c->getTrustedDomainHelper()->isTrustedDomain($c->getRequest()->getInsecureServerHost())) {
$imageManager = new ImageManager(
$c->get(\OCP\IConfig::class),
$c->getAppDataDir('theming'),

@ -410,7 +410,7 @@ class Setup {
// create empty file in data dir, so we can later find
// out that this is indeed an ownCloud data directory
file_put_contents($config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data') . '/.ocdata', '');
file_put_contents($config->getSystemValueString('datadirectory', \OC::$SERVERROOT . '/data') . '/.ocdata', '');
// Update .htaccess files
self::updateHtaccess();
@ -585,7 +585,7 @@ class Setup {
$content .= " IndexIgnore *\n";
$content .= "</IfModule>";
$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', '');
}

@ -1179,7 +1179,7 @@ class Manager implements IManager {
* Set the share's password expiration time
*/
private function setSharePasswordExpirationTime(IShare $share): void {
if (!$this->config->getSystemValue('sharing.enable_mail_link_password_expiration', false)) {
if (!$this->config->getSystemValueBool('sharing.enable_mail_link_password_expiration', false)) {
// Sets password expiration date to NULL
$share->setPasswordExpirationTime();
return;

@ -176,7 +176,7 @@ class Registry implements IRegistry {
}
$userCount = $this->getUserCount();
$hardUserLimit = $this->config->getSystemValue('one-click-instance.user-limit', 50);
$hardUserLimit = $this->config->getSystemValueInt('one-click-instance.user-limit', 50);
$userLimitReached = $userCount >= $hardUserLimit;
if ($userLimitReached && $notificationManager instanceof IManager) {

@ -221,7 +221,7 @@ class TemplateLayout extends \OC_Template {
// TODO: remove deprecated OC_Util injection
$jsFiles = self::findJavascriptFiles(array_merge(\OC_Util::$scripts, Util::getScripts()));
$this->assign('jsfiles', []);
if ($this->config->getSystemValue('installed', false) && $renderAs != TemplateResponse::RENDER_AS_ERROR) {
if ($this->config->getSystemValueBool('installed', false) && $renderAs != TemplateResponse::RENDER_AS_ERROR) {
// this is on purpose outside of the if statement below so that the initial state is prefilled (done in the getConfig() call)
// see https://github.com/nextcloud/server/pull/22636 for details
$jsConfigHelper = new JSConfigHelper(
@ -304,14 +304,14 @@ class TemplateLayout extends \OC_Template {
* @return string
*/
protected function getVersionHashSuffix($path = false, $file = false) {
if ($this->config->getSystemValue('debug', false)) {
if ($this->config->getSystemValueBool('debug', false)) {
// allows chrome workspace mapping in debug mode
return "";
}
$themingSuffix = '';
$v = [];
if ($this->config->getSystemValue('installed', false)) {
if ($this->config->getSystemValueBool('installed', false)) {
if (\OC::$server->getAppManager()->isInstalled('theming')) {
$themingSuffix = '-' . $this->config->getAppValue('theming', 'cachebuster', '0');
}

@ -141,7 +141,7 @@ class URLGenerator implements IURLGenerator {
* Returns a url to the given app and file.
*/
public function linkTo(string $appName, string $file, array $args = []): string {
$frontControllerActive = ($this->config->getSystemValue('htaccess.IgnoreFrontController', false) === true || getenv('front_controller_active') === 'true');
$frontControllerActive = ($this->config->getSystemValueBool('htaccess.IgnoreFrontController', false) || getenv('front_controller_active') === 'true');
if ($appName !== '') {
$app_path = $this->getAppManager()->getAppPath($appName);
@ -214,7 +214,7 @@ class URLGenerator implements IURLGenerator {
// Check if the app is in the app folder
$path = '';
$themingEnabled = $this->config->getSystemValue('installed', false) && $this->getAppManager()->isEnabledForUser('theming');
$themingEnabled = $this->config->getSystemValueBool('installed', false) && $this->getAppManager()->isEnabledForUser('theming');
$themingImagePath = false;
if ($themingEnabled) {
$themingDefaults = \OC::$server->getThemingDefaults();
@ -275,7 +275,7 @@ class URLGenerator implements IURLGenerator {
$separator = strpos($url, '/') === 0 ? '' : '/';
if (\OC::$CLI && !\defined('PHPUNIT_RUN')) {
return rtrim($this->config->getSystemValue('overwrite.cli.url'), '/') . '/' . ltrim($url, '/');
return rtrim($this->config->getSystemValueString('overwrite.cli.url'), '/') . '/' . ltrim($url, '/');
}
// The ownCloud web root can already be prepended.
if (\OC::$WEBROOT !== '' && strpos($url, \OC::$WEBROOT) === 0) {
@ -313,7 +313,7 @@ class URLGenerator implements IURLGenerator {
$appId = $this->getAppManager()->getDefaultAppForUser();
if ($this->config->getSystemValue('htaccess.IgnoreFrontController', false) === true
if ($this->config->getSystemValueBool('htaccess.IgnoreFrontController', false)
|| getenv('front_controller_active') === 'true') {
return $this->getAbsoluteURL('/apps/' . $appId . '/');
}

@ -129,7 +129,7 @@ class Updater extends BasicEmitter {
}
}
$installedVersion = $this->config->getSystemValue('version', '0.0.0');
$installedVersion = $this->config->getSystemValueString('version', '0.0.0');
$currentVersion = implode('.', \OCP\Util::getVersion());
$this->log->debug('starting upgrade from ' . $installedVersion . ' to ' . $currentVersion, ['app' => 'core']);
@ -216,7 +216,7 @@ class Updater extends BasicEmitter {
if ($currentVendor === 'nextcloud') {
return isset($allowedPreviousVersions[$currentVendor][$majorMinor])
&& (version_compare($oldVersion, $newVersion, '<=') ||
$this->config->getSystemValue('debug', false));
$this->config->getSystemValueBool('debug', false));
}
// Check if the instance can be migrated
@ -251,7 +251,7 @@ class Updater extends BasicEmitter {
// create empty file in data dir, so we can later find
// out that this is indeed an ownCloud data directory
// (in case it didn't exist before)
file_put_contents($this->config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data') . '/.ocdata', '');
file_put_contents($this->config->getSystemValueString('datadirectory', \OC::$SERVERROOT . '/data') . '/.ocdata', '');
// pre-upgrade repairs
$repair = new Repair(Repair::getBeforeUpgradeRepairSteps(), \OC::$server->get(\OCP\EventDispatcher\IEventDispatcher::class), \OC::$server->get(LoggerInterface::class));
@ -399,7 +399,7 @@ class Updater extends BasicEmitter {
* @return bool
*/
private function isCodeUpgrade(): bool {
$installedVersion = $this->config->getSystemValue('version', '0.0.0');
$installedVersion = $this->config->getSystemValueString('version', '0.0.0');
$currentVersion = implode('.', Util::getVersion());
if (version_compare($currentVersion, $installedVersion, '>')) {
return true;

@ -64,7 +64,7 @@ class VersionCheck {
return json_decode($this->config->getAppValue('core', 'lastupdateResult'), true);
}
$updaterUrl = $this->config->getSystemValue('updater.server.url', 'https://updates.nextcloud.com/updater_server/');
$updaterUrl = $this->config->getSystemValueString('updater.server.url', 'https://updates.nextcloud.com/updater_server/');
$this->config->setAppValue('core', 'lastupdatedat', (string)time());

@ -447,7 +447,7 @@ class Database extends ABackend implements
*/
public function getHome(string $uid) {
if ($this->userExists($uid)) {
return \OC::$server->getConfig()->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data') . '/' . $uid;
return \OC::$server->getConfig()->getSystemValueString('datadirectory', \OC::$SERVERROOT . '/data') . '/' . $uid;
}
return false;

@ -491,8 +491,8 @@ class Session implements IUserSession, Emitter {
return false;
}
private function isTokenAuthEnforced() {
return $this->config->getSystemValue('token_auth_enforced', false);
private function isTokenAuthEnforced(): bool {
return $this->config->getSystemValueBool('token_auth_enforced', false);
}
protected function isTwoFactorEnforced($username) {
@ -958,7 +958,7 @@ class Session implements IUserSession, Emitter {
$webRoot = '/';
}
$maxAge = $this->config->getSystemValue('remember_login_cookie_lifetime', 60 * 60 * 24 * 15);
$maxAge = $this->config->getSystemValueInt('remember_login_cookie_lifetime', 60 * 60 * 24 * 15);
\OC\Http\CookieHelper::setCookie(
'nc_username',
$username,

@ -363,7 +363,7 @@ class User implements IUser {
if (($this->backend instanceof IGetHomeBackend || $this->backend->implementsActions(Backend::GET_HOME)) && $home = $this->backend->getHome($this->uid)) {
$this->home = $home;
} elseif ($this->config) {
$this->home = $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data') . '/' . $this->uid;
$this->home = $this->config->getSystemValueString('datadirectory', \OC::$SERVERROOT . '/data') . '/' . $this->uid;
} else {
$this->home = \OC::$SERVERROOT . '/data/' . $this->uid;
}
@ -416,7 +416,7 @@ class User implements IUser {
* @return bool
*/
public function canChangeDisplayName() {
if ($this->config->getSystemValue('allow_user_to_change_display_name') === false) {
if (!$this->config->getSystemValueBool('allow_user_to_change_display_name')) {
return false;
}
return $this->backend->implementsActions(Backend::SET_DISPLAYNAME);

@ -49,7 +49,7 @@ class OC_FileChunking {
*/
public function __construct($info) {
$this->info = $info;
$this->ttl = \OC::$server->getConfig()->getSystemValue('cache_chunk_gc_ttl', 86400);
$this->ttl = \OC::$server->getConfig()->getSystemValueInt('cache_chunk_gc_ttl', 86400);
}
public function getPrefix() {

@ -634,6 +634,6 @@ class OC_Helper {
* @return bool
*/
public static function isReadOnlyConfigEnabled() {
return \OC::$server->getConfig()->getSystemValue('config_is_read_only', false);
return \OC::$server->getConfig()->getSystemValueBool('config_is_read_only', false);
}
}

@ -185,7 +185,7 @@ class OC_Util {
/** @var LoggerInterface $logger */
$logger = \OC::$server->get(LoggerInterface::class);
$plainSkeletonDirectory = \OC::$server->getConfig()->getSystemValue('skeletondirectory', \OC::$SERVERROOT . '/core/skeleton');
$plainSkeletonDirectory = \OC::$server->getConfig()->getSystemValueString('skeletondirectory', \OC::$SERVERROOT . '/core/skeleton');
$userLang = \OC::$server->getL10NFactory()->findLanguage();
$skeletonDirectory = str_replace('{lang}', $userLang, $plainSkeletonDirectory);
@ -306,7 +306,7 @@ class OC_Util {
*/
public static function getChannel() {
OC_Util::loadVersion();
return \OC::$server->getConfig()->getSystemValue('updater.release.channel', self::$versionCache['OC_Channel']);
return \OC::$server->getConfig()->getSystemValueString('updater.release.channel', self::$versionCache['OC_Channel']);
}
/**
@ -783,7 +783,7 @@ class OC_Util {
* @return array arrays with error messages and hints
*/
public static function checkDataDirectoryPermissions($dataDirectory) {
if (\OC::$server->getConfig()->getSystemValue('check_data_directory_permissions', true) === false) {
if (!\OC::$server->getConfig()->getSystemValueBool('check_data_directory_permissions', true)) {
return [];
}
@ -957,7 +957,7 @@ class OC_Util {
$testContent = 'This is used for testing whether htaccess is properly enabled to disallow access from the outside. This file can be safely removed.';
// creating a test file
$testFile = $config->getSystemValue('datadirectory', OC::$SERVERROOT . '/data') . '/' . $fileName;
$testFile = $config->getSystemValueString('datadirectory', OC::$SERVERROOT . '/data') . '/' . $fileName;
if (file_exists($testFile)) {// already running this test, possible recursive call
return false;
@ -983,7 +983,7 @@ class OC_Util {
* @throws \OCP\HintException If the test file can't get written.
*/
public function isHtaccessWorking(\OCP\IConfig $config) {
if (\OC::$CLI || !$config->getSystemValue('check_for_working_htaccess', true)) {
if (\OC::$CLI || !$config->getSystemValueBool('check_for_working_htaccess', true)) {
return true;
}
@ -993,7 +993,7 @@ class OC_Util {
}
$fileName = '/htaccesstest.txt';
$testFile = $config->getSystemValue('datadirectory', OC::$SERVERROOT . '/data') . '/' . $fileName;
$testFile = $config->getSystemValueString('datadirectory', OC::$SERVERROOT . '/data') . '/' . $fileName;
// accessing the file via http
$url = \OC::$server->getURLGenerator()->getAbsoluteURL(OC::$WEBROOT . '/data' . $fileName);

Loading…
Cancel
Save