diff --git a/.gsoc/todo.txt b/.gsoc/todo.txt index 570b1dd9d..959835c0c 100644 --- a/.gsoc/todo.txt +++ b/.gsoc/todo.txt @@ -7,10 +7,3 @@ info about setup script in prefs manage, it seems many people still don't know i show blacklist (and debug?) on prefs manage page - - -/* if (!isset($this->persistKeys[$canonical_path]) - // equality but only if both values are numeric or not numeric, allows to skip 0 == 'auto' - && (($value == $default_value && !(is_numeric($value) xor is_numeric($value))) - || - (empty($value) && empty($default_value)))) {*/ diff --git a/libraries/config/FormDisplay.class.php b/libraries/config/FormDisplay.class.php index a176c3bdf..5a08f5e87 100644 --- a/libraries/config/FormDisplay.class.php +++ b/libraries/config/FormDisplay.class.php @@ -461,9 +461,14 @@ class FormDisplay */ private function _validateSelect(&$value, array $allowed) { + $value_cmp = is_bool($value) + ? (int) $value + : $value; foreach ($allowed as $vk => $v) { - // force string comparison so that 0 isn't equal to any string - if ((string)$value == (string)$vk) { + // equality comparison only if both values are numeric or not numeric + // (allows to skip 0 == 'string' equalling to true) or identity (for string-string) + if (($vk == $value && !(is_numeric($value_cmp) xor is_numeric($vk))) + || $vk === $value) { settype($value, gettype($v)); return true; } diff --git a/prefs_manage.php b/prefs_manage.php index 3df224988..bd085593e 100644 --- a/prefs_manage.php +++ b/prefs_manage.php @@ -87,14 +87,16 @@ if (isset($_POST['submit_export']) && filter_input(INPUT_POST, 'export_type') == } } $cf = ConfigFile::getInstance(); - if (empty($_POST['import_merge'])) { - $cf->resetConfigData(); + $new_config = $cf->getFlatDefaultConfig(); + if (!empty($_POST['import_merge'])) { + $new_config = array_merge($new_config, $cf->getConfigArray()); } + $new_config = array_merge($new_config, $config); $_POST_bak = $_POST; - foreach ($cf->getFlatDefaultConfig() as $k => $v) { + foreach ($new_config as $k => $v) { $_POST[str_replace('/', '-', $k)] = $v; } - $_POST = array_merge($_POST, $config); + $cf->resetConfigData(); $all_ok = $form_display->process(true, false); $all_ok = $all_ok && !$form_display->hasErrors(); $_POST = $_POST_bak;