This is a javaScript bug under auto complete module.

Essentially, acdb.cache is being populated with a wrong key when callback function 'receive' is called after the 'searchString' variable is updated by 'search' function.

The fix is to pass a copy of old 'searchString' to 'receive' funtion.

See the file for my fix.

CommentFileSizeAuthor
code.txt1.4 KBDT

Comments

Zen’s picture

Please submit your modifications in patch form.

-K

chx’s picture

Version: 4.6.5 » x.y.z

I have no idea of this but one thing for sure. autocomplete is no 4.6 but HEAD

budda’s picture

I think the offending line is 263:
acdb.cache[acdb.searchString] = matches;

From what DT is saying, the acdb.searchString may well have changed between the time taken for the results to be sent from the server to the client.

A copy of acdb.searchString should be passed in to the recieve() function to ensure the matches are associated with the right search string.

From looking at the autocomplete.js code, it appears only one ACDB object is created per autocomplete field on the page. If you have a page with two username boxes, and searched in both at the same time, its possible that the matches would be mixed with the wrong search key.

I've not tested the above, its just based on what DT said and observing ythe JavaScript.

magico’s picture

A patch or a test case to reproduce this bug should be provided.

bdragon’s picture

Version: x.y.z » 6.x-dev
Status: Active » Closed (duplicate)

How can any javascript be thread-unsafe? Javascript is not threaded. It uses an event queue.

In any case, I believe this has been fixed since by locking down the whole shebang while searching. If this is still an issue, please reopen...