Arguments mismatch between Ajax and core callback

Created on 12 July 2017, over 7 years ago
Updated 15 September 2024, 3 months ago

Autocomplete was getting sluggish, and I discovered that the callback was returning ALL results. The limit was not being respected.

It appears the url structure set by Ajax and the arguments passed on to the callback do not match.

In autocomplete_deluxe.js:

var url = settings.uri + '/' + self.limit + '/' + term;

In autocomplete_deluxe.module:

function autocomplete_deluxe_taxonomy_callback($field_name, $tags_typed = '', $limit = 10) {
  $args = array_slice(func_get_args(), 2);
  $tags_typed = implode('/', $args);
}

A sample ajax request to this url http://localhost/autocomplete_deluxe/taxonomy/field_tags/10/examp?term=e... will set the arguments:

  • $field_name => field_tags
  • $tags_typed => 10
  • $limit => examp

While the $tags_typed is later set to the correct value using func_get_args, I think this should not have been necessary if the arguments were set properly.

The limit in this case is set to a non-numeric value and does not get used by the query builder. Hence, the query will return ALL results.

Also, the callback seems to be doing some weird trick with the $tags_types variable, which I think, is completely unnecessary here.

I have taken the liberty to refactor the callback with a patch.

πŸ› Bug report
Status

Closed: outdated

Version

2.2

Component

Code (miscellaneous)

Created by

πŸ‡ΊπŸ‡ΈUnited States stimalsina

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024