node_search() passes an empty query to db_rewrite_sql() instead of the actaul query to perform. this is not the spirit of this hook. move db_rewrite_sql() call to later during the query build process.

CommentFileSizeAuthor
#8 do_search.patch5.81 KBjsaints
#5 do_search.patch5.77 KBDavid Lesieur

Comments

Robrecht Jacques’s picture

Does this still apply?

I don't find a call to db_rewrite_sql() in node_search(). I do find a _db_rewrite_sql() in node_search('search'). Is that what you mean?

Please elaborate.

moshe weitzman’s picture

Title: Pass real sql through db_rewrite_sql() » Stop avoiding db_rewrite_sql() in node_search()

yes, i refer to _db_rewrite_sql()

changed title to be more clear.

moshe weitzman’s picture

Version: x.y.z » 7.x-dev
robertdouglass’s picture

Yes. This needs to be done as part of a refactoring of do_search since the query fragments present in node_search aren't really sufficient to do the db_rewrite_sql() in their current form. I suppose it belongs in do_search and any specific information that db_rewrite_sql needs has to be passed into do_search as well. Or we make a nice query builder that can replace do_search.

David Lesieur’s picture

Status: Active » Needs work
StatusFileSize
new5.77 KB

LIVE FROM THE MINNESOTA SEARCH SPRINT! Here's a patch that refactors do_search() slightly... It has some pros and cons:

Pros:

  • Private function _db_rewrite_sql() no longer called from node_search(); db_rewrite_sql() is used instead.
  • New function search_build_query() allows modules to get the SQL and then call whatever query function they need (e.g. db_query(), pager_query(), db_query_temporary()).

Cons:

  • An additional query is necessary for finding out whether the search has any results (before, do_search() returned immediately with an empty result set when the normalization query failed).
  • do_search() becomes quite empty and perhaps not very relevant.

However, this patch might become a (small) first step towards a larger issue encompassing search query parsing and building...

robertdouglass’s picture

Priority: Normal » Critical
swentel’s picture

Patch doesn't apply anymore at this point, I'll investigate later to try and fix it.

[swentel@swenteltop drupal]$ patch -p0 < do_search.patch 
patching file modules/node/node.module
Hunk #1 succeeded at 1249 (offset 56 lines).
Hunk #2 FAILED at 1342.
1 out of 2 hunks FAILED -- saving rejects to file modules/node/node.module.rej
patching file modules/search/search.module
Hunk #1 succeeded at 859 (offset 2 lines).
Hunk #2 FAILED at 908.
1 out of 3 hunks FAILED -- saving rejects to file modules/search/search.module.rej
patching file modules/search/search.test
jsaints’s picture

StatusFileSize
new5.81 KB

Playing patch bingo... saw that this needed to be updated for HEAD. I rerolled the patch for HEAD and verified that all tests pass without failure or exception.

I cannot vouch for the functional merit of this patch. I am not that familliar with the search.module. I notice, tough, that a few respected drupalers seem to think its quite important. So here it is, re-rolled for HEAD (D7).

Thanks

jsaints’s picture

Status: Needs work » Needs review

patch is ready for review.

Anonymous’s picture

Status: Needs review » Needs work

The last submitted patch failed testing.

chx’s picture

Status: Needs work » Closed (won't fix)

DBTNG fixed this. yay.