diff --git a/lib/private/Config/Lexicon/CoreConfigLexicon.php b/lib/private/Config/Lexicon/CoreConfigLexicon.php index f6bc586677be0..34a0b883c5406 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 @@ * 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 @@ public function getStrictness(): ConfigLexiconStrictness { /** * @inheritDoc * @return ConfigLexiconEntry[] - * @since 31.0.0 */ public function getAppConfigs(): array { return [ @@ -40,7 +34,6 @@ public function getAppConfigs(): array { /** * @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 ed225409d1c0c..776cce08d676b 100644 --- a/lib/private/Config/UserConfig.php +++ b/lib/private/Config/UserConfig.php @@ -229,7 +229,8 @@ public function isLazy(string $userId, string $app, string $key): bool { // 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 @@ public function getValues( $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 @@ private function getTypedValue( ): 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 @@ private function setTypedValue( ): 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 @@ private function setTypedValue( $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 @@ private function setTypedValue( 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 @@ public function updateGlobalSensitive(string $app, string $key, bool $sensitive) } } - $this->clearCacheAll(); // we clear all cache + // we clear all cache + $this->clearCacheAll(); } /** @@ -1371,7 +1378,8 @@ public function updateGlobalIndexed(string $app, string $key, bool $indexed): vo } } - $this->clearCacheAll(); // we clear all cache + // we clear all cache + $this->clearCacheAll(); } /** @@ -1794,6 +1802,14 @@ private function convertTypedValue(string $value, ValueType $type): string|int|f } + /** + * 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 @@ private function decryptSensitiveValue(string $userId, string $app, string $key, * * @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 @@ private function matchAndApplyLexiconDefinition( * ], * * 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 2cf196113f7aa..d7d781d8e2654 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;