I'm noticing that the query generated for my view changes when I have a taxonomy term that includes a space in the name. For example, the url http://mysite.com/foo/One Term, generates the following where clause in the query:
WHERE (( (node.status = '1') AND (taxonomy_term_data_taxonomy_index__taxonomy_term_data.name IN ('One', 'Term')) ))
ORDER BY node_created DESC
However, shouldn't this build the where clause to say
WHERE ( (node.status = '1') AND (node.type IN ('facilities', 'parks') AND (taxonomy_term_data_taxonomy_index__taxonomy_term_data.name IN ('One Term') ) ))
ORDER BY node_created DESC ?
I have my view set up to accept multiple arguments, and I have also enabled replacing spaces with dashes, but neither of these should affect the generation of the one term, right?
Any help would be greatly appreciated.
Thank you!
Comment | File | Size | Author |
---|---|---|---|
#13 | 1153370-fix-phrase-string.patch | 1.28 KB | dawehner |
#4 | view_example.txt | 4.13 KB | Anonymous (not verified) |
Comments
Comment #1
merlinofchaos CreditAttribution: merlinofchaos commentedThat's because spaces get translated to + by the URL and the + is the OR separator.
Your URL needs to contain %20 for the space, which is the HTML entity for a space.
Comment #2
Anonymous (not verified) CreditAttribution: Anonymous commentedHi, thanks for the quick reply. Actually, there is a %20 in the url, I removed it for readability sake.
When I use %20 in the Auto Preview of the view, for example One%20Term, the where clause returns:
WHERE (( (node.status = '1') AND (taxonomy_term_data_taxonomy_index__taxonomy_term_data.name = '-1') ))
Any idea why a -1 is returned and not the term? Could someone point me in the direction of where that query is generated?
Thanks so much.
Comment #3
merlinofchaos CreditAttribution: merlinofchaos commentedThere is a giant link pointing to the guidelines for issue tags. PLEASE READ THEM BEFORE TYPING RANDOM TAGS into the field. Please respect our processes on drupal.org.
The entirety of Views is a query generator. Specifically that part of a query is going to be generated by an argument handler for the argument you're using, and it could be affected by the argument validation plugin.
Since you didn't attach an export of the view, I can't tell you why that data gets transformed into a -1. I can't think of anything that should convert that to a -1. Perhaps there is a bug with transforming them, perhaps you've got something configured badly. Hard to say.
Comment #4
Anonymous (not verified) CreditAttribution: Anonymous commentedI'm sorry about the issue tags, it won't happen again.
I went ahead and attached a very basic view export that uses the same taxonomy filter to display an html list. It is set up to accept multiple arguments. The multiple arguments works just fine, until you introduce a taxonomy term that has a space (%20) in it.
Ex... (Foo,Bar) works fine, but (Foo,Bar,Two%20Words) does not.
Additionally, I am using CTools 7.x-1.0-alpha4 with Views 7.x-3.0-beta3.
Thanks again for your time.
Comment #5
merlinofchaos CreditAttribution: merlinofchaos commentedSorry, I shouldn't have been so forceful about the issue tags. Built up reaction; lots of people do it and I overreacted on this one. I'll try to be more polite on that in the future.
My guess is there's a bug with the string separation. Can you turn that feature off and try it? I bet the -1 will not appear.
Comment #6
Anonymous (not verified) CreditAttribution: Anonymous commentedNo worries, I should have read it to begin with.
You are right, when I disable multiple values, it works just fine for one taxonomy value with a space in the name.
The view I am trying to build, obviously, needs the multiple terms. I'll see what I can do in terms of a fix, but I'm pretty new to the D7 code, so finding it might take me a bit.
Thanks again for your patience!
Comment #7
merlinofchaos CreditAttribution: merlinofchaos commentedYou can use multiple values as multiple arguments by selecting the option that allows multiple arguments that work together. That could be a workaround but you'll be limited in how many you can use.
Comment #8
dawehnerIt could be that the views_break_string method has a bug here.
Let's check this first.
Comment #9
dawehnerThe break_string phase returns -1 if there is no valid input.
But at least until now " " or "+" breaks the string to OR and "," to AND.
The bug of this issue seems to be that " " breaks, but it shouldn't. I don't really see this.
An additional behaviour i see is that if you input "foo,bar" you get a execution runtime error.
Comment #10
Anonymous (not verified) CreditAttribution: Anonymous commentedI think I've narrowed it down to the function views_break_phrase_string() in /includes/handlers.inc.
This either breaks up the string incorrectly, or skips the statement completely when it shouldn't. I'm still trying to get a handle on what the regex is doing, so hopefully I'll have more soon.
Comment #11
dawehnerThat's interesting, i did quite some testing in code for this, see this:
Comment #12
dawehnertested with node: title
It worked fine.
Back to your input:
That's currently how it is. You can either split by comma OR by space, which means AND or OR.
Perhaps the "," seperator should come first and ignore the comma.
Comment #13
dawehnerHere is a patch which fixes the issue for me + a changed test.
Comment #14
dawehnerCommited to 6.x-3.x and 7.x-3.x because the simpletest are running fine.