diff -u b/core/modules/taxonomy/taxonomy.module b/core/modules/taxonomy/taxonomy.module --- b/core/modules/taxonomy/taxonomy.module +++ b/core/modules/taxonomy/taxonomy.module @@ -310,6 +310,7 @@ $items['taxonomy/autocomplete/%'] = array( 'title' => 'Autocomplete taxonomy', 'page callback' => 'taxonomy_autocomplete', + 'page arguments' => array(2), 'access arguments' => array('access content'), 'type' => MENU_CALLBACK, 'file' => 'taxonomy.pages.inc', diff -u b/core/modules/views/includes/ajax.inc b/core/modules/views/includes/ajax.inc --- b/core/modules/views/includes/ajax.inc +++ b/core/modules/views/includes/ajax.inc @@ -281,11 +281,19 @@ /** * Page callback for views user autocomplete. * + * @param string $string + * (optional) A comma-separated list of user names entered in the + * autocomplete form element. If not passed, it is taken from the 'q' query + * string parameter. + * * @return Symfony\Component\HttpFoundation\JsonResponse */ -function views_ajax_autocomplete_user() { +function views_ajax_autocomplete_user($string = NULL) { + if (!isset($string)) { + $string = drupal_container()->get('request')->query->get('q'); + } // The user enters a comma-separated list of user name. We only autocomplete the last name. - $array = drupal_explode_tags(drupal_container()->get('request')->query->get('q')); + $array = drupal_explode_tags($string); // Fetch last name $last_string = trim(array_pop($array)); diff -u b/core/modules/views/views_ui/admin.inc b/core/modules/views/views_ui/admin.inc --- b/core/modules/views/views_ui/admin.inc +++ b/core/modules/views/views_ui/admin.inc @@ -2095,9 +2095,11 @@ /** * Page callback for views tag autocomplete */ -function views_ui_autocomplete_tag() { +function views_ui_autocomplete_tag($string = NULL) { $matches = array(); - $string = drupal_container()->get('request')->query->get('q'); + if (!isset($string)) { + $string = drupal_container()->get('request')->query->get('q'); + } // get matches from default views: $views = views_get_all_views(); foreach ($views as $view) { only in patch2: unchanged: --- a/core/modules/system/lib/Drupal/system/Tests/Theme/FastTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Theme/FastTest.php @@ -39,7 +39,7 @@ function setUp() { */ function testUserAutocomplete() { $this->drupalLogin($this->account); - $this->drupalGet('user/autocomplete/' . $this->account->name); + $this->drupalGet('user/autocomplete', array('query' => array('q' => $this->account->name))); $this->assertRaw($this->account->name); $this->assertNoText('registry initialized', 'The registry was not initialized'); } only in patch2: unchanged: --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTest.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTest.php @@ -205,13 +205,13 @@ function testNodeTermCreationAndDeletion() { // Test autocomplete on term 3, which contains a comma. // The term will be quoted, and the " will be encoded in unicode (\u0022). $input = substr($term_objects['term3']->name, 0, 3); - $json = $this->drupalGet('taxonomy/autocomplete/taxonomy_' . $this->vocabulary->machine_name . '/' . $input); + $json = $this->drupalGet('taxonomy/autocomplete/taxonomy_' . $this->vocabulary->machine_name, array('query' => array('q' => $input))); $this->assertEqual($json, '{"\u0022' . $term_objects['term3']->name . '\u0022":"' . $term_objects['term3']->name . '"}', format_string('Autocomplete returns term %term_name after typing the first 3 letters.', array('%term_name' => $term_objects['term3']->name))); // Test autocomplete on term 4 - it is alphanumeric only, so no extra // quoting. $input = substr($term_objects['term4']->name, 0, 3); - $this->drupalGet('taxonomy/autocomplete/taxonomy_' . $this->vocabulary->machine_name . '/' . $input); + $this->drupalGet('taxonomy/autocomplete/taxonomy_' . $this->vocabulary->machine_name, array('query' => array('q' => $input))); $this->assertRaw('{"' . $term_objects['term4']->name . '":"' . $term_objects['term4']->name . '"}', format_string('Autocomplete returns term %term_name after typing the first 3 letters.', array('%term_name' => $term_objects['term4']->name))); // Test taxonomy autocomplete with a nonexistent field. @@ -219,7 +219,7 @@ function testNodeTermCreationAndDeletion() { $tag = $this->randomName(); $message = t("Taxonomy field @field_name not found.", array('@field_name' => $field_name)); $this->assertFalse(field_info_field($field_name), format_string('Field %field_name does not exist.', array('%field_name' => $field_name))); - $this->drupalGet('taxonomy/autocomplete/' . $field_name . '/' . $tag); + $this->drupalGet('taxonomy/autocomplete/' . $field_name, array('query' => array('q' => $tag))); $this->assertRaw($message, 'Autocomplete returns correct error message when the taxonomy field does not exist.'); } @@ -243,10 +243,9 @@ function testTermAutocompletion() { // Try to autocomplete a term name that matches both terms. // We should get both term in a json encoded string. $input = '10/'; - $path = 'taxonomy/autocomplete/taxonomy_'; - $path .= $this->vocabulary->machine_name . '/' . $input; + $path = 'taxonomy/autocomplete/taxonomy_' . $this->vocabulary->machine_name; // The result order is not guaranteed, so check each term separately. - $result = $this->drupalGet($path); + $result = $this->drupalGet($path, array('query' => array('q' => $input))); $data = drupal_json_decode($result); $this->assertEqual($data[$first_term->name], check_plain($first_term->name), 'Autocomplete returned the first matching term'); $this->assertEqual($data[$second_term->name], check_plain($second_term->name), 'Autocomplete returned the second matching term'); @@ -254,17 +253,15 @@ function testTermAutocompletion() { // Try to autocomplete a term name that matches first term. // We should only get the first term in a json encoded string. $input = '10/16'; - $url = 'taxonomy/autocomplete/taxonomy_'; - $url .= $this->vocabulary->machine_name . '/' . $input; - $this->drupalGet($url); + $path = 'taxonomy/autocomplete/taxonomy_' . $this->vocabulary->machine_name; + $this->drupalGet($path, array('query' => array('q' => $input))); $target = array($first_term->name => check_plain($first_term->name)); $this->assertRaw(drupal_json_encode($target), 'Autocomplete returns only the expected matching term.'); // Try to autocomplete a term name with both a comma and a slash. $input = '"term with, comma and / a'; - $url = 'taxonomy/autocomplete/taxonomy_'; - $url .= $this->vocabulary->machine_name . '/' . $input; - $this->drupalGet($url); + $path = 'taxonomy/autocomplete/taxonomy_' . $this->vocabulary->machine_name; + $this->drupalGet($path, array('query' => array('q' => $input))); $n = $third_term->name; // Term names containing commas or quotes must be wrapped in quotes. if (strpos($third_term->name, ',') !== FALSE || strpos($third_term->name, '"') !== FALSE) { only in patch2: unchanged: --- a/core/modules/user/lib/Drupal/user/Tests/UserAutocompleteTest.php +++ b/core/modules/user/lib/Drupal/user/Tests/UserAutocompleteTest.php @@ -35,13 +35,13 @@ function setUp() { function testUserAutocomplete() { // Check access from unprivileged user, should be denied. $this->drupalLogin($this->unprivileged_user); - $this->drupalGet('user/autocomplete/' . $this->unprivileged_user->name[0]); + $this->drupalGet('user/autocomplete', array('query' => array('q' => $this->unprivileged_user->name[0]))); $this->assertResponse(403, 'Autocompletion access denied to user without permission.'); // Check access from privileged user. $this->drupalLogout(); $this->drupalLogin($this->privileged_user); - $this->drupalGet('user/autocomplete/' . $this->unprivileged_user->name[0]); + $this->drupalGet('user/autocomplete', array('query' => array('q' => $this->unprivileged_user->name[0]))); $this->assertResponse(200, 'Autocompletion access allowed.'); // Using first letter of the user's name, make sure the user's full name is in the results.