diff options
author | Robin McCorkell <rmccorkell@owncloud.com> | 2015-08-20 12:23:12 +0100 |
---|---|---|
committer | Robin McCorkell <rmccorkell@owncloud.com> | 2015-08-20 12:23:12 +0100 |
commit | 643e3a5b6db19b9ba0210fef89f6ee163bc0edef (patch) | |
tree | 1406164f94b09de42e8508e99d081bb9563fd2a9 /apps/files_external/lib/definitionparameter.php | |
parent | 62d328525a264015ba1f7035aed2e75de69f5cdd (diff) | |
download | nextcloud-server-643e3a5b6db19b9ba0210fef89f6ee163bc0edef.tar.gz nextcloud-server-643e3a5b6db19b9ba0210fef89f6ee163bc0edef.zip |
Convert string booleans to real booleans
Legacy compatibility, from the days in stable8 when checkbox boolean
values were stored as the strings 'true' and 'false'.
Diffstat (limited to 'apps/files_external/lib/definitionparameter.php')
-rw-r--r-- | apps/files_external/lib/definitionparameter.php | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/apps/files_external/lib/definitionparameter.php b/apps/files_external/lib/definitionparameter.php index 4b560908b69..7f883e5fad1 100644 --- a/apps/files_external/lib/definitionparameter.php +++ b/apps/files_external/lib/definitionparameter.php @@ -154,22 +154,31 @@ class DefinitionParameter implements \JsonSerializable { /** * Validate a parameter value against this + * Convert type as necessary * * @param mixed $value Value to check * @return bool success */ - public function validateValue($value) { - if ($this->getFlags() & self::FLAG_OPTIONAL) { - return true; - } + public function validateValue(&$value) { + $optional = $this->getFlags() & self::FLAG_OPTIONAL; + switch ($this->getType()) { case self::VALUE_BOOLEAN: if (!is_bool($value)) { - return false; + switch ($value) { + case 'true': + $value = true; + break; + case 'false': + $value = false; + break; + default: + return false; + } } break; default: - if (empty($value)) { + if (!$value && !$optional) { return false; } break; |