I've run into an odd bug on a site using this module - if you search for a word of less than 3 characters, and then, from the custom search block on the page that returns, search for something different, the search results returned are for the original (less than 3 character) word, not the new search terms.

Example: if I search just for the word "of" (and yes, I realize it's highly unlikely anyone would ever actually do this on purpose - it was discovered by someone accidentally hitting return too soon), the URL of the page returned is search/node/of, and it shows the usual error message about needing to include at least one positive keyword with 3 characters or more, plus a custom search block that allows users to customize their search by node type, taxonomy terms, etc. But if I then enter "history of community gardens" (or whatever) there and search again, the page that produces is *not* search/node/history of community gardens as you might expect, it's still search/node/of, with the same error message as before. The page does refresh, but what it returns is the same as what was there before.

This happens regardless of whether I use the search box in the block or in the site header, and it keeps happening even if I search repeatedly. The only way to get it to search for the new phrase successfully is to go to a different page and search from there.

It does not happen if you search for a word or phrase of more than 3 characters initially - only if the initial search term was too short.

If I disable the Custom Search module, this no longer happens, so it's definitely something to do with this module.

I can get around it for now by lowering the minimum word length to 1 in the search settings, but obviously that's not an ideal solution, as it's going to bloat the database up considerably. And if it was my own site, I probably wouldn't even worry about it, since people aren't likely to search for a word of less than 3 characters very often. But this is a client's site, and it was the client who discovered the bug, and they'd like it fixed just in case. So if there's anything I can do about this (apart from lowering the minimum word length as I've already done), please do let me know.


jdanthinne’s picture

Project:Custom Search» Drupal core
Version:7.x-1.11» 7.x-dev
Component:Miscellaneous» search.module

I've just double-checked, and this happens with Custom Search disabled as well, this is a Core search bug.

GoddamnNoise’s picture

I've just accidentally found this bug in one of my Drupal 7 sites. I've checked all my other Drupal 7 sites and they all have the same bug. I've not installed the Custom Search module in any of these sites, this is a Core search bug.

jhodgdon’s picture

OK, we'll have to look into this. Thanks for the report!

GoddamnNoise’s picture

Hi again,

I've been testing this in Drupal 7 for a while and i've found some interesting things, so i'll share them just in case it could help to solve this annoying bug.

Once you search for a word of less than 3 characters from the Search block (let's say you search for the word 'x'), the action attribute of the form tag for the Search block (the form with id='search-block-form') will never change even if you search for another different word from that search block (searching for a word of less than 3 characters or of more than 3 characters has no different effects). The action attribute will remain being 'node/search/x' until you visit another page or until you search from the form located over the search results (that form with id='search-form').

Besides that, once you search for a word of less than 3 characters from the Search block, the 'search_box_form_submit' function is never executed again when you submit the Search Block form. I don't know why!, but it only gets executed the first time.

This is all what i've been able to find until now. I hope this could help. I'll dig deeper if someone points me in the right direction (i don't have enough knowledge about Drupal to realize what could be happening here).

jhodgdon’s picture

Thanks! That seems like very helpful information.

If someone wants to test this in 8.x, that would also be helpful (we will have to see if this applies to 8.x and fix it there first if it does).

GoddamnNoise’s picture

I've just tested it in a Drupal 8 fresh install, and... yes, i've seen exactly the same odd behaviour in Drupal 8.

jhodgdon’s picture

Version:7.x-dev» 8.x-dev
Priority:Normal» Major

Thanks -- your efforts are much appreciated! This sounds like an important bug that we need to address, so I'm changing the version and upping the priority.

GoddamnNoise’s picture

Thanks to you!.

swentel’s picture

This relates to #1789768: search_box_form_submit() improperly calls form_set_error() - maybe even duplicates this when the other one is fixed.

GoddamnNoise’s picture

Yes, after reading #1789768: search_box_form_submit() improperly calls form_set_error(), it seems they are the same issue.

jhodgdon’s picture

Status:Active» Closed (duplicate)

I had no idea! Let's close this one as a duplicate then and make sure the priority of the other one is also "major" if it is causing this result. I'll take care of it. Again, thanks for all the testing!