diff options
author | Joas Schilling <nickvergessen@owncloud.com> | 2015-12-09 13:32:52 +0100 |
---|---|---|
committer | Joas Schilling <nickvergessen@owncloud.com> | 2016-01-14 15:02:54 +0100 |
commit | 00ab50defc7a683907df59fd503b24a35decf962 (patch) | |
tree | 6a0c9373879f0e294716ae0bb3ee49dec5e82ffb /core/command | |
parent | b9d384d837b0400933d71701f0bcfcd38fe4285b (diff) | |
download | nextcloud-server-00ab50defc7a683907df59fd503b24a35decf962.tar.gz nextcloud-server-00ab50defc7a683907df59fd503b24a35decf962.zip |
Retain backwards compatibility
Diffstat (limited to 'core/command')
-rw-r--r-- | core/command/config/system/setconfig.php | 107 |
1 files changed, 56 insertions, 51 deletions
diff --git a/core/command/config/system/setconfig.php b/core/command/config/system/setconfig.php index 83a969fd55d..f05b8d6ead3 100644 --- a/core/command/config/system/setconfig.php +++ b/core/command/config/system/setconfig.php @@ -83,7 +83,7 @@ class SetConfig extends Base { $existingValue = $this->systemConfig->getValue($configName); $newValue = $this->mergeArrayValue( - array_slice($configNames, 1), $existingValue, $configValue, $updateOnly + array_slice($configNames, 1), $existingValue, $configValue['value'], $updateOnly ); $this->systemConfig->setValue($configName, $newValue); @@ -92,10 +92,10 @@ class SetConfig extends Base { throw new \UnexpectedValueException('Config parameter does not exist'); } - $this->systemConfig->setValue($configName, $configValue); + $this->systemConfig->setValue($configName, $configValue['value']); } - $output->writeln('<info>System config value ' . implode(' => ', $configNames) . ' set to ' . $configValue . '</info>'); + $output->writeln('<info>System config value ' . implode(' => ', $configNames) . ' set to ' . $configValue['readable-value'] . '</info>'); return 0; } @@ -106,57 +106,62 @@ class SetConfig extends Base { * @throws \InvalidArgumentException */ protected function castValue($value, $type) { - if ($value === null) { - return null; - } - - $type = strtolower($type); switch ($type) { - case 'string': - case 'str': - case 's': - return $value; - - case 'integer': - case 'int': - case 'i': - if (!is_numeric($value)) { - throw new \InvalidArgumentException('Non-numeric value specified'); - } - return (int) $value; - - case 'double': - case 'd': - case 'float': - case 'f': - if (!is_numeric($value)) { - throw new \InvalidArgumentException('Non-numeric value specified'); - } - return (double) $value; - - case 'boolean': - case 'bool': - case 'b': - $value = strtolower($value); - switch ($value) { - case 'true': - case 'yes': - case 'y': - case '1': - return true; - - case 'false': - case 'no': - case 'n': - case '0': - return false; + case 'integer': + case 'int': + if (!is_numeric($value)) { + throw new \InvalidArgumentException('Non-numeric value specified'); + } + return [ + 'value' => (int) $value, + 'readable-value' => 'integer ' . (int) $value, + ]; + + case 'double': + case 'float': + if (!is_numeric($value)) { + throw new \InvalidArgumentException('Non-numeric value specified'); + } + return [ + 'value' => (double) $value, + 'readable-value' => 'double ' . (double) $value, + ]; + + case 'boolean': + case 'bool': + $value = strtolower($value); + switch ($value) { + case 'true': + return [ + 'value' => true, + 'readable-value' => 'boolean ' . $value, + ]; + + case 'false': + return [ + 'value' => false, + 'readable-value' => 'boolean ' . $value, + ]; + + default: + throw new \InvalidArgumentException('Unable to parse value as boolean'); + } + + case 'null': + return [ + 'value' => null, + 'readable-value' => 'null', + ]; + + case 'string': + $value = (string) $value; + return [ + 'value' => $value, + 'readable-value' => ($value === '') ? 'empty string' : 'string ' . $value, + ]; default: - throw new \InvalidArgumentException('Unable to parse value as boolean'); - } - - default: - throw new \InvalidArgumentException('Invalid type'); + throw new \InvalidArgumentException('Invalid type'); } } |