diff options
author | Maxence Lange <maxence@artificial-owl.com> | 2025-06-17 19:02:08 +0200 |
---|---|---|
committer | Maxence Lange <maxence@artificial-owl.com> | 2025-06-19 11:04:11 +0200 |
commit | 1b42dad8f3863e4c9d602340d0109bffdc8e9bfd (patch) | |
tree | fbb3c7a1ad827aec557b64465b5e2c5213ca0348 | |
parent | 6bba89aa2ad3c8e14e72dd560af0e14924116f3c (diff) | |
download | nextcloud-server-feat/noid/lexicon-migrate-keys.tar.gz nextcloud-server-feat/noid/lexicon-migrate-keys.zip |
feat(lexicon): better numeric conversionfeat/noid/lexicon-migrate-keys
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
-rw-r--r-- | lib/private/AppConfig.php | 1 | ||||
-rw-r--r-- | lib/private/Config/ConfigManager.php | 4 | ||||
-rw-r--r-- | lib/private/Config/UserConfig.php | 1 |
3 files changed, 4 insertions, 2 deletions
diff --git a/lib/private/AppConfig.php b/lib/private/AppConfig.php index 4048e32cca1..b6412b410bb 100644 --- a/lib/private/AppConfig.php +++ b/lib/private/AppConfig.php @@ -480,6 +480,7 @@ class AppConfig implements IAppConfig { // in case the key was modified while running matchAndApplyLexiconDefinition() we are // interested to check options in case a modification of the value is needed + // ie inverting value from previous key when using lexicon option RENAME_INVERT_BOOLEAN if ($origKey !== $key && $type === self::VALUE_BOOL) { $configManager = Server::get(ConfigManager::class); $value = ($configManager->convertToBool($value, $this->getLexiconEntry($app, $key))) ? '1' : '0'; diff --git a/lib/private/Config/ConfigManager.php b/lib/private/Config/ConfigManager.php index 08deb4c84d3..1980269e2ca 100644 --- a/lib/private/Config/ConfigManager.php +++ b/lib/private/Config/ConfigManager.php @@ -205,7 +205,7 @@ class ConfigManager { } public function convertToInt(string $value): int { - if ($value !== ((string)((int)$value))) { + if (!is_numeric($value) || (float)$value <> (int)$value) { throw new TypeConflictException('Value is not an integer'); } @@ -213,7 +213,7 @@ class ConfigManager { } public function convertToFloat(string $value): float { - if ($value !== ((string)((float)$value))) { + if (!is_numeric($value)) { throw new TypeConflictException('Value is not a float'); } diff --git a/lib/private/Config/UserConfig.php b/lib/private/Config/UserConfig.php index 59d6439b3bd..7a49a932737 100644 --- a/lib/private/Config/UserConfig.php +++ b/lib/private/Config/UserConfig.php @@ -760,6 +760,7 @@ class UserConfig implements IUserConfig { // in case the key was modified while running matchAndApplyLexiconDefinition() we are // interested to check options in case a modification of the value is needed + // ie inverting value from previous key when using lexicon option RENAME_INVERT_BOOLEAN if ($origKey !== $key && $type === ValueType::BOOL) { $configManager = Server::get(ConfigManager::class); $value = ($configManager->convertToBool($value, $this->getLexiconEntry($app, $key))) ? '1' : '0'; |