diff options
Diffstat (limited to 'includes')
-rw-r--r-- | includes/common.inc | 4 | ||||
-rw-r--r-- | includes/form.inc | 9 |
2 files changed, 6 insertions, 7 deletions
diff --git a/includes/common.inc b/includes/common.inc index 211695c8e..a301f3404 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -2481,7 +2481,9 @@ function drupal_exit($destination = NULL) { * An associative array. */ function drupal_map_assoc($array, $function = NULL) { - $array = array_combine($array, $array); + // array_combine() fails with empty arrays: + // http://bugs.php.net/bug.php?id=34857. + $array = !empty($array) ? array_combine($array, $array) : array(); if (is_callable($function)) { $array = array_map($function, $array); } diff --git a/includes/form.inc b/includes/form.inc index c1ba70bf4..3cd6bca81 100644 --- a/includes/form.inc +++ b/includes/form.inc @@ -941,7 +941,7 @@ function _form_validate(&$elements, &$form_state, $form_id = NULL) { $options = $elements['#options']; } if (is_array($elements['#value'])) { - $value = $elements['#type'] == 'checkboxes' ? array_keys(array_filter($elements['#value'])) : $elements['#value']; + $value = $elements['#type'] == 'checkboxes' ? array_keys($elements['#value']) : $elements['#value']; foreach ($value as $v) { if (!isset($options[$v])) { form_error($elements, $t('An illegal choice has been detected. Please contact the site administrator.')); @@ -1804,11 +1804,8 @@ function form_type_checkboxes_value($element, $input = FALSE) { } return $value; } - // If the checkboxes are enabled, and NULL input is submitted, it means - // they're intentionally unchecked, so we need to return an empty array to - // prevent the default value from being used. - elseif (!isset($input) && empty($element['#disabled'])) { - return array(); + else { + return is_array($input) ? drupal_map_assoc($input) : array(); } } |