diff --git a/includes/common.inc b/includes/common.inc index f6171cf..585bb7c 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -3878,7 +3878,15 @@ function drupal_html_id($id) { // requested id. $_POST['ajax_html_ids'] contains the ids as they were // returned by this function, potentially with the appended counter, so // we parse that to reconstruct the $seen_ids array. - foreach ($_POST['ajax_html_ids'] as $seen_id) { + if (is_array($_POST['ajax_html_ids'])) { + $ajax_html_ids = $_POST['ajax_html_ids']; + } + else { + // For some reason (http://drupal.org/node/1575060) jquery.form.js can send string instead of array. + // So we need to convert recieved data into an array to keep the logic. + $ajax_html_ids = explode(',', $_POST['ajax_html_ids']); + } + foreach ($ajax_html_ids as $seen_id) { // We rely on '--' being used solely for separating a base id from the // counter, which this function ensures when returning an id. $parts = explode('--', $seen_id, 2); diff --git a/modules/simpletest/drupal_web_test_case.php b/modules/simpletest/drupal_web_test_case.php index 694880b..5ab1c14 100644 --- a/modules/simpletest/drupal_web_test_case.php +++ b/modules/simpletest/drupal_web_test_case.php @@ -2154,9 +2154,12 @@ class DrupalWebTestCase extends DrupalTestCase { $extra_post .= '&' . urlencode($key) . '=' . urlencode($value); } } + $ajax_html_ids = array(); foreach ($this->xpath('//*[@id]') as $element) { - $id = (string) $element['id']; - $extra_post .= '&' . urlencode('ajax_html_ids[]') . '=' . urlencode($id); + $ajax_html_ids[] = (string) $element['id']; + } + if (!empty($ajax_html_ids)) { + $extra_post .= '&' . urlencode('ajax_html_ids') . '=' . urlencode(implode(',', $ajax_html_ids)); } if (isset($drupal_settings['ajaxPageState'])) { $extra_post .= '&' . urlencode('ajax_page_state[theme]') . '=' . urlencode($drupal_settings['ajaxPageState']['theme']);