Stop avoiding db_rewrite_sql() in node_search()

moshe weitzman - March 18, 2006 - 03:30
Project:Drupal
Version:7.x-dev
Component:search.module
Category:bug report
Priority:critical
Assigned:Unassigned
Status:won't fix
Description

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.

#1

Robrecht Jacques - September 13, 2006 - 18:03

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.

#2

moshe weitzman - September 13, 2006 - 20:50
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.

#3

moshe weitzman - January 6, 2008 - 04:41
Version:x.y.z» 7.x-dev

#4

robertDouglass - April 15, 2008 - 10:28

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.

#5

David Lesieur - May 10, 2008 - 22:52
Status:active» needs work

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...

AttachmentSize
do_search.patch 5.77 KB
Testbed results
do_search.patchfailedFailed: Failed to apply patch. Detailed results

#6

robertDouglass - August 13, 2008 - 06:53
Priority:normal» critical

#7

swentel - August 13, 2008 - 19:12

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

#8

jsaints - October 5, 2008 - 19:48

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

AttachmentSize
do_search.patch 5.81 KB
Testbed results
do_search.patchfailedFailed: Failed to apply patch. Detailed results

#9

jsaints - October 5, 2008 - 19:50
Status:needs work» needs review

patch is ready for review.

#10

Anonymous (not verified) - November 12, 2008 - 09:05
Status:needs review» needs work

The last submitted patch failed testing.

#11

chx - June 2, 2009 - 01:58
Status:needs work» won't fix

DBTNG fixed this. yay.

 
 

Drupal is a registered trademark of Dries Buytaert.