mirror of
https://github.com/nextcloud/server.git
synced 2026-06-11 09:42:09 -04:00
feat(lexicon): better numeric conversion
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
This commit is contained in:
parent
d29e1dc380
commit
d860cfd1cb
3 changed files with 4 additions and 2 deletions
|
|
@ -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';
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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';
|
||||
|
|
|
|||
Loading…
Reference in a new issue