diff --git a/core/modules/user/lib/Drupal/user/Plugin/views/filter/Name.php b/core/modules/user/lib/Drupal/user/Plugin/views/filter/Name.php index b12eb0780d22cfafed02210b922f103586d25a2c..bb3c4b33a1c7d5dab16b0236ece56efff0f0ae83 100644 --- a/core/modules/user/lib/Drupal/user/Plugin/views/filter/Name.php +++ b/core/modules/user/lib/Drupal/user/Plugin/views/filter/Name.php @@ -45,7 +45,7 @@ function value_form(&$form, &$form_state) { '#title' => t('Usernames'), '#description' => t('Enter a comma separated list of user names.'), '#default_value' => $default_value, - '#autocomplete_path' => 'admin/views/ajax/autocomplete/user', + '#autocomplete_path' => 'user/autocomplete/anonymous', ); if (!empty($form_state['exposed']) && !isset($form_state['input'][$this->options['expose']['identifier']])) { diff --git a/core/modules/user/lib/Drupal/user/Tests/Views/HandlerFilterUserNameTest.php b/core/modules/user/lib/Drupal/user/Tests/Views/HandlerFilterUserNameTest.php index 45a1424a34772e2e6a6ed7578888a4ea4474e36b..cc0d38f3d5b80b61887ed6e839da13c6b3649fdc 100644 --- a/core/modules/user/lib/Drupal/user/Tests/Views/HandlerFilterUserNameTest.php +++ b/core/modules/user/lib/Drupal/user/Tests/Views/HandlerFilterUserNameTest.php @@ -176,26 +176,4 @@ public function testExposedFilter() { } } - /** - * Tests the autocomplete function. - * - * @see views_ajax_autocomplete_user - */ - public function testUserAutocomplete() { - module_load_include('inc', 'views', 'includes/ajax'); - - // Nothing should return no user. - $result = (array) json_decode(views_ajax_autocomplete_user('')); - $this->assertFalse($result); - - // A random user should also not be findable. - $result = (array) json_decode(views_ajax_autocomplete_user($this->randomName())->getContent()); - $this->assertFalse($result); - - // A valid user should be found. - $result = (array) json_decode(views_ajax_autocomplete_user($this->names[0])->getContent()); - $expected_result = array($this->names[0] => $this->names[0]); - $this->assertIdentical($result, $expected_result); - } - } diff --git a/core/modules/views/includes/ajax.inc b/core/modules/views/includes/ajax.inc index 61f913cd880940e2b2617b1c8e20274269a6d6a7..73c3d0213f5139f2973b7794b2ef950d9a314679 100644 --- a/core/modules/views/includes/ajax.inc +++ b/core/modules/views/includes/ajax.inc @@ -278,53 +278,6 @@ function views_ajax_form_wrapper($form_id, &$form_state) { return $output; } -/** - * 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($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($string); - - // Fetch last name - $last_string = trim(array_pop($array)); - $matches = array(); - if ($last_string != '') { - $prefix = count($array) ? implode(', ', $array) . ', ' : ''; - - if (strpos('anonymous', strtolower($last_string)) !== FALSE) { - $matches[$prefix . 'Anonymous'] = 'Anonymous'; - } - - $result = db_select('users', 'u') - ->fields('u', array('uid', 'name')) - ->condition('u.name', db_like($last_string) . '%', 'LIKE') - ->range(0, 10) - ->execute() - ->fetchAllKeyed(); - - foreach ($result as $account) { - $n = $account; - // Commas and quotes in terms are special cases, so encode 'em. - if (strpos($account, ',') !== FALSE || strpos($account, '"') !== FALSE) { - $n = '"' . str_replace('"', '""', $account) . '"'; - } - $matches[$prefix . $n] = check_plain($account); - } - } - - return new JsonResponse($matches); -} - /** * Page callback for views taxonomy autocomplete. * diff --git a/core/modules/views/views.module b/core/modules/views/views.module index 8a85c976127123b1109ba5e00a6671fdc9b931ec..9de0ff2f638fc2589bb2008ef9c5da8727892da3 100644 --- a/core/modules/views/views.module +++ b/core/modules/views/views.module @@ -304,16 +304,6 @@ function views_menu() { 'type' => MENU_CALLBACK, 'file' => 'includes/ajax.inc', ); - // Path is not admin/structure/views due to menu complications with the wildcards from - // the generic ajax callback. - $items['admin/views/ajax/autocomplete/user'] = array( - 'page callback' => 'views_ajax_autocomplete_user', - 'theme callback' => 'ajax_base_page_theme', - 'access callback' => 'user_access', - 'access arguments' => array('access content'), - 'type' => MENU_CALLBACK, - 'file' => 'includes/ajax.inc', - ); // Define another taxonomy autocomplete because the default one of drupal // does not support a vid a argument anymore $items['admin/views/ajax/autocomplete/taxonomy/%'] = array(