I have 3 elements in a finder view: province (select list that allows multiple values), text and category (select list). The text is searched in node titles and node bodies.

The WHERE clause of the SQL query is wrong when submitting this values: "Badajoz" and "Ciudad Real", "word", and "comunidad":

WHERE ((((term_data_2.name = 'Badajoz') OR (term_data_2.name = 'Ciudad Real'))) AND (((node_revisions.body LIKE '%Badajoz%' OR node.title LIKE '%Ciudad Real%'))) AND (((node.type = 'word'))))

The correct clause is this:

WHERE ((((term_data_2.name = 'Badajoz') OR (term_data_2.name = 'Ciudad Real'))) AND (((node_revisions.body LIKE '%word%' OR node.title LIKE '%word%'))) AND (((node.type = 'comunidad'))))

I've seen the problem is the array $inner_clause_args. This array is passed to $this->view->query->add_where, used in finder/modules/finder_views/includes/finder_views_plugin_display_finder.inc on line 77.

This array contains: Array ( [0] => Badajoz [1] => Ciudad Real [2] => Badajoz [3] => Ciudad Real ) Array ( [0] => word [1] => word ) Array ( [0] => comunidad )

The correct content is: Array ( [0] => Badajoz [1] => Ciudad Real ) Array ( [0] => word [1] => word ) Array ( [0] => comunidad )

I've made a patch that solved the problem. I hope is useful

CommentFileSizeAuthor
finder_views_bug.patch821 bytesopor

Comments

agtempleton’s picture

I was having this same issue with Finder, so I tried the fix and it resolved the problem. Would it be possible to roll this patch into the release?

danielb’s picture

Well I'd like to, but there is very little info/discussion here about the bug/solution on a code level apart from:

I've seen the problem is the array $inner_clause_args.

??

So I need to figure out what he's done, what was wrong, why the fix works, does it break anything else, etc...
Been bitten before with random patches, and both of you are new members with no other posts.

agtempleton’s picture

That's true, I'm new to posting here. For me, the problem was that I had a search that needed to work like this:

(property1 OR property2 OR property3) AND (compound1 OR compound2 OR compound3)

when I implemented finder, it worked great for single item searches or (prop1) AND (comp1), but returned no results whenever I tried to run a search with more that one item in each element. When I did a var dump I noticed that the terms from element1 (prop) were being thrown into the array for element2 (comp), and element2 terms weren't being included at all.

What other information can I provide you with to help you out? Let me know.

danielb’s picture

Status: Active » Fixed

Hmm yeah I notice extra args are being passed, but I can't get it to break the functionality. I guess that might depend on exactly the use-case. Your patch does appear to remove the extra args though, so I'll stick it in. Thanks.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

danielb’s picture

Status: Closed (fixed) » Active

turns out the solution in this issue also breaks some finders, and reverting the patch fixes it.
The bug must be caused earlier on or something so I will investigate further

danielb’s picture

Status: Active » Fixed

If anyone continues to have this problem with releases after this date please reopen. The example in #4 causes me no dramas.

samgen’s picture

Status: Fixed » Needs review

I wrote about this issue in http://drupal.org/node/1142298

Still causes me problems with multiple values in conjunction.

danielb’s picture

Status: Needs review » Closed (fixed)