aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/private/Config/Lexicon/CoreConfigLexicon.php9
-rw-r--r--lib/private/Config/UserConfig.php41
-rw-r--r--lib/unstable/Config/Lexicon/ConfigLexiconEntry.php2
-rw-r--r--tests/Core/Command/Config/App/GetConfigTest.php5
4 files changed, 29 insertions, 28 deletions
diff --git a/lib/private/Config/Lexicon/CoreConfigLexicon.php b/lib/private/Config/Lexicon/CoreConfigLexicon.php
index f6bc586677b..34a0b883c54 100644
--- a/lib/private/Config/Lexicon/CoreConfigLexicon.php
+++ b/lib/private/Config/Lexicon/CoreConfigLexicon.php
@@ -3,7 +3,7 @@
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
- * SPDX-License-Identifier: AGPL-3.0-only
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OC\Config\Lexicon;
@@ -17,11 +17,6 @@ use NCU\Config\ValueType;
* ConfigLexicon for 'core' app/user configs
*/
class CoreConfigLexicon implements IConfigLexicon {
- /**
- * @inheritDoc
- * @return ConfigLexiconStrictness
- * @since 31.0.0
- */
public function getStrictness(): ConfigLexiconStrictness {
return ConfigLexiconStrictness::IGNORE;
}
@@ -29,7 +24,6 @@ class CoreConfigLexicon implements IConfigLexicon {
/**
* @inheritDoc
* @return ConfigLexiconEntry[]
- * @since 31.0.0
*/
public function getAppConfigs(): array {
return [
@@ -40,7 +34,6 @@ class CoreConfigLexicon implements IConfigLexicon {
/**
* @inheritDoc
* @return ConfigLexiconEntry[]
- * @since 31.0.0
*/
public function getUserConfigs(): array {
return [
diff --git a/lib/private/Config/UserConfig.php b/lib/private/Config/UserConfig.php
index ed225409d1c..776cce08d67 100644
--- a/lib/private/Config/UserConfig.php
+++ b/lib/private/Config/UserConfig.php
@@ -229,7 +229,8 @@ class UserConfig implements IUserConfig {
// there is a huge probability the non-lazy config are already loaded
// meaning that we can start by only checking if a current non-lazy key exists
if ($this->hasKey($userId, $app, $key, false)) {
- return false; // meaning key is not lazy.
+ // meaning key is not lazy.
+ return false;
}
// as key is not found as non-lazy, we load and search in the lazy config
@@ -264,7 +265,8 @@ class UserConfig implements IUserConfig {
$values = array_filter(
$this->formatAppValues($userId, $app, ($this->fastCache[$userId][$app] ?? []) + ($this->lazyCache[$userId][$app] ?? []), $filtered),
function (string $key) use ($prefix): bool {
- return str_starts_with($key, $prefix); // filter values based on $prefix
+ // filter values based on $prefix
+ return str_starts_with($key, $prefix);
}, ARRAY_FILTER_USE_KEY
);
@@ -713,7 +715,8 @@ class UserConfig implements IUserConfig {
): string {
$this->assertParams($userId, $app, $key);
if (!$this->matchAndApplyLexiconDefinition($userId, $app, $key, $lazy, $type, default: $default)) {
- return $default; // returns default if strictness of lexicon is set to WARNING (block and report)
+ // returns default if strictness of lexicon is set to WARNING (block and report)
+ return $default;
}
$this->loadConfig($userId, $lazy);
@@ -1048,7 +1051,8 @@ class UserConfig implements IUserConfig {
): bool {
$this->assertParams($userId, $app, $key);
if (!$this->matchAndApplyLexiconDefinition($userId, $app, $key, $lazy, $type, $flags)) {
- return false; // returns false as database is not updated
+ // returns false as database is not updated
+ return false;
}
$this->loadConfig($userId, $lazy);
@@ -1101,7 +1105,8 @@ class UserConfig implements IUserConfig {
$inserted = true;
} catch (DBException $e) {
if ($e->getReason() !== DBException::REASON_UNIQUE_CONSTRAINT_VIOLATION) {
- throw $e; // TODO: throw exception or just log and returns false !?
+ // TODO: throw exception or just log and returns false !?
+ throw $e;
}
}
}
@@ -1196,7 +1201,8 @@ class UserConfig implements IUserConfig {
public function updateType(string $userId, string $app, string $key, ValueType $type = ValueType::MIXED): bool {
$this->assertParams($userId, $app, $key);
$this->loadConfigAll($userId);
- $this->isLazy($userId, $app, $key); // confirm key exists
+ // confirm key exists
+ $this->isLazy($userId, $app, $key);
$update = $this->connection->getQueryBuilder();
$update->update('preferences')
@@ -1288,7 +1294,8 @@ class UserConfig implements IUserConfig {
}
}
- $this->clearCacheAll(); // we clear all cache
+ // we clear all cache
+ $this->clearCacheAll();
}
/**
@@ -1371,7 +1378,8 @@ class UserConfig implements IUserConfig {
}
}
- $this->clearCacheAll(); // we clear all cache
+ // we clear all cache
+ $this->clearCacheAll();
}
/**
@@ -1794,6 +1802,14 @@ class UserConfig implements IUserConfig {
}
+ /**
+ * will change referenced $value with the decrypted value in case of encrypted (sensitive value)
+ *
+ * @param string $userId
+ * @param string $app
+ * @param string $key
+ * @param string $value
+ */
private function decryptSensitiveValue(string $userId, string $app, string $key, string &$value): void {
if (!$this->isFlagged(self::FLAG_SENSITIVE, $this->valueDetails[$userId][$app][$key]['flags'] ?? 0)) {
return;
@@ -1821,6 +1837,7 @@ class UserConfig implements IUserConfig {
*
* @throws UnknownKeyException
* @throws TypeConflictException
+ * @return bool FALSE if conflict with defined lexicon were observed in the process
*/
private function matchAndApplyLexiconDefinition(
string $userId,
@@ -1874,16 +1891,12 @@ class UserConfig implements IUserConfig {
* ],
*
* The entry is converted to string to fit the expected type when managing default value
- *
- * @param string $appId
- * @param ConfigLexiconEntry $configValue
- *
- * @return string|null
*/
private function getSystemDefault(string $appId, ConfigLexiconEntry $configValue): ?string {
$default = $this->config->getSystemValue('lexicon.default.userconfig', [])[$appId][$configValue->getKey()] ?? null;
if ($default === null) {
- return null; // no system default, using default default.
+ // no system default, using default default.
+ return null;
}
return $configValue->convertToString($default);
diff --git a/lib/unstable/Config/Lexicon/ConfigLexiconEntry.php b/lib/unstable/Config/Lexicon/ConfigLexiconEntry.php
index 2cf196113f7..d7d781d8e26 100644
--- a/lib/unstable/Config/Lexicon/ConfigLexiconEntry.php
+++ b/lib/unstable/Config/Lexicon/ConfigLexiconEntry.php
@@ -3,7 +3,7 @@
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
- * SPDX-License-Identifier: AGPL-3.0-only
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace NCU\Config\Lexicon;
diff --git a/tests/Core/Command/Config/App/GetConfigTest.php b/tests/Core/Command/Config/App/GetConfigTest.php
index 33e50699bbe..c1a6265db40 100644
--- a/tests/Core/Command/Config/App/GetConfigTest.php
+++ b/tests/Core/Command/Config/App/GetConfigTest.php
@@ -101,11 +101,6 @@ class GetConfigTest extends TestCase {
->method('getDetails')
->with('app-name', $configName)
->willReturn(['value' => $value]);
- } else {
- $this->config->expects($this->once())
- ->method('getValueMixed')
- ->with('app-name', $configName, $defaultValue)
- ->willReturn($defaultValue);
}
}