aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaxence Lange <maxence@artificial-owl.com>2024-12-12 17:37:14 -0100
committerMaxence Lange <maxence@artificial-owl.com>2024-12-13 11:08:20 -0100
commit815991741d2001f7610047ef9627283037c1beec (patch)
tree6250d5998b5f4d1c13f00606c8a7634d12ed1886
parent96586ba7095b3d955b093bc34d696654faa80252 (diff)
downloadnextcloud-server-feature/noid/config-lexicon.tar.gz
nextcloud-server-feature/noid/config-lexicon.zip
fix(lexicon): renaming and minor fixesfeature/noid/config-lexicon
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
-rw-r--r--lib/private/AppConfig.php8
-rw-r--r--lib/private/Config/UserConfig.php10
-rw-r--r--lib/unstable/Config/Lexicon/ConfigLexiconEntry.php2
-rw-r--r--lib/unstable/Config/Lexicon/ConfigLexiconStrictness.php10
-rw-r--r--tests/lib/AppConfigTest.php4
5 files changed, 15 insertions, 19 deletions
diff --git a/lib/private/AppConfig.php b/lib/private/AppConfig.php
index bb439218015..71c958703e9 100644
--- a/lib/private/AppConfig.php
+++ b/lib/private/AppConfig.php
@@ -436,7 +436,7 @@ class AppConfig implements IAppConfig {
int $type,
): string {
$this->assertParams($app, $key, valueType: $type);
- if (!$this->compareRegisteredConfigValues($app, $key, $lazy, $type, $default)) {
+ if (!$this->matchAndApplyLexiconDefinition($app, $key, $lazy, $type, $default)) {
return $default; // returns default if strictness of lexicon is set to WARNING (block and report)
}
$this->loadConfig($app, $lazy);
@@ -730,7 +730,7 @@ class AppConfig implements IAppConfig {
int $type,
): bool {
$this->assertParams($app, $key);
- if (!$this->compareRegisteredConfigValues($app, $key, $lazy, $type)) {
+ if (!$this->matchAndApplyLexiconDefinition($app, $key, $lazy, $type)) {
return false; // returns false as database is not updated
}
$this->loadConfig(null, $lazy);
@@ -1573,13 +1573,13 @@ class AppConfig implements IAppConfig {
}
/**
- * verify and compare current use of config values with defined lexicon
+ * match and apply current use of config values with defined lexicon
*
* @throws AppConfigUnknownKeyException
* @throws AppConfigTypeConflictException
* @return bool TRUE if everything is fine compared to lexicon or lexicon does not exist
*/
- private function compareRegisteredConfigValues(
+ private function matchAndApplyLexiconDefinition(
string $app,
string $key,
bool &$lazy,
diff --git a/lib/private/Config/UserConfig.php b/lib/private/Config/UserConfig.php
index b2242729d2b..78c43fc4321 100644
--- a/lib/private/Config/UserConfig.php
+++ b/lib/private/Config/UserConfig.php
@@ -711,7 +711,7 @@ class UserConfig implements IUserConfig {
ValueType $type,
): string {
$this->assertParams($userId, $app, $key);
- if (!$this->compareRegisteredConfigValues($app, $key, $lazy, $type, default: $default)) {
+ if (!$this->matchAndApplyLexiconDefinition($app, $key, $lazy, $type, default: $default)) {
return $default; // returns default if strictness of lexicon is set to WARNING (block and report)
}
$this->loadConfig($userId, $lazy);
@@ -1046,7 +1046,7 @@ class UserConfig implements IUserConfig {
ValueType $type,
): bool {
$this->assertParams($userId, $app, $key);
- if (!$this->compareRegisteredConfigValues($app, $key, $lazy, $type, $flags)) {
+ if (!$this->matchAndApplyLexiconDefinition($app, $key, $lazy, $type, $flags)) {
return false; // returns false as database is not updated
}
$this->loadConfig($userId, $lazy);
@@ -1816,12 +1816,12 @@ class UserConfig implements IUserConfig {
}
/**
- * verify and compare current use of config values with defined lexicon
+ * match and apply current use of config values with defined lexicon
*
* @throws UnknownKeyException
* @throws TypeConflictException
*/
- private function compareRegisteredConfigValues(
+ private function matchAndApplyLexiconDefinition(
string $app,
string $key,
bool &$lazy,
@@ -1837,7 +1837,7 @@ class UserConfig implements IUserConfig {
/** @var ConfigLexiconEntry $configValue */
$configValue = $configDetails['entries'][$key];
if ($type === ValueType::MIXED) {
- $type = $configValue->getValueType()->value; // we overwrite if value was requested as mixed
+ $type = $configValue->getValueType(); // we overwrite if value was requested as mixed
} elseif ($configValue->getValueType() !== $type) {
throw new TypeConflictException('The user config key ' . $app . '/' . $key . ' is typed incorrectly in relation to the config lexicon');
}
diff --git a/lib/unstable/Config/Lexicon/ConfigLexiconEntry.php b/lib/unstable/Config/Lexicon/ConfigLexiconEntry.php
index 68787f9000c..e6c6579881d 100644
--- a/lib/unstable/Config/Lexicon/ConfigLexiconEntry.php
+++ b/lib/unstable/Config/Lexicon/ConfigLexiconEntry.php
@@ -174,7 +174,7 @@ class ConfigLexiconEntry {
* @experimental 31.0.0
*/
public function isFlagged(int $flag): bool {
- return (bool)($flag & $this->getFlags());
+ return (($flag & $this->getFlags()) === $flag);
}
/**
diff --git a/lib/unstable/Config/Lexicon/ConfigLexiconStrictness.php b/lib/unstable/Config/Lexicon/ConfigLexiconStrictness.php
index fda0adb0037..a6490675c8a 100644
--- a/lib/unstable/Config/Lexicon/ConfigLexiconStrictness.php
+++ b/lib/unstable/Config/Lexicon/ConfigLexiconStrictness.php
@@ -18,13 +18,13 @@ namespace NCU\Config\Lexicon;
*
* @experimental 31.0.0
*/
-enum ConfigLexiconStrictness: int {
+enum ConfigLexiconStrictness {
/** @experimental 31.0.0 */
- case IGNORE = 0; // fully ignore
+ case IGNORE; // fully ignore
/** @experimental 31.0.0 */
- case NOTICE = 2; // ignore and report
+ case NOTICE; // ignore and report
/** @experimental 31.0.0 */
- case WARNING = 3; // silently block (returns $default) and report
+ case WARNING; // silently block (returns $default) and report
/** @experimental 31.0.0 */
- case EXCEPTION = 5; // block (throws exception) and report
+ case EXCEPTION; // block (throws exception) and report
}
diff --git a/tests/lib/AppConfigTest.php b/tests/lib/AppConfigTest.php
index 775c9027dd6..518d7909d70 100644
--- a/tests/lib/AppConfigTest.php
+++ b/tests/lib/AppConfigTest.php
@@ -9,7 +9,6 @@ namespace Test;
use InvalidArgumentException;
use OC\AppConfig;
-use OC\AppFramework\Bootstrap\Coordinator;
use OCP\Exceptions\AppConfigTypeConflictException;
use OCP\Exceptions\AppConfigUnknownKeyException;
use OCP\IAppConfig;
@@ -29,7 +28,6 @@ class AppConfigTest extends TestCase {
protected IDBConnection $connection;
private LoggerInterface $logger;
private ICrypto $crypto;
- private Coordinator $coordinator;
private array $originalConfig;
@@ -91,7 +89,6 @@ class AppConfigTest extends TestCase {
$this->connection = \OCP\Server::get(IDBConnection::class);
$this->logger = \OCP\Server::get(LoggerInterface::class);
$this->crypto = \OCP\Server::get(ICrypto::class);
- $this->coordinator = \OCP\Server::get(Coordinator::class);
// storing current config and emptying the data table
$sql = $this->connection->getQueryBuilder();
@@ -182,7 +179,6 @@ class AppConfigTest extends TestCase {
$this->connection,
$this->logger,
$this->crypto,
- $this->coordinator
);
$msg = ' generateAppConfig() failed to confirm cache status';