I have a views (Export Views.txt & Capture 1.jpg) and I get the error in Capture 2.jpg. One taxonomy term exposed is configured as (Capture 3.jpg, Capture 4.jpg & Capture 5.JPG). The other taxonomy filter exposed is exactly the same but i select Catalog as the vocabulary (Capture 3.jpg). The OR/AND conditions are configured as Capture 6.jpg.

Am I doing something wrong?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dawehner’s picture

Status: Active » Fixed
FileSize
64.21 KB

This might be fixed in the meantime.

Therefore please update to the real latest version . It works fine here, see screenshot

EndEd’s picture

Status: Fixed » Active

Hi dereine. I just download the latest views version but I still have the same errors.

One thing i find different about your image attachment is that you dont seem to have WHERE in the query. It seem that you imported my attachment view but please, could you double check if the same conditions are applied on the filters as you see in (Capture 3.jpg, Capture 4.jpg, Capture 5.jpg & Capture 6.jpg)?

Also in your attachment i see the 'An invalid vocabulary is selected. Please change it in options.' Maybe as you don't have the exact same vocabulary as i have is not replicating the same conditions. I dont know.

In my case it partially works only if:

1. I remove the pager, selecting the 'display all item' option. I this case i dont get the error but if i select 2 or more terms from the same Taxonomy term exposed filter, it gives me 0 results and it suppose to give me around 8 results.

2. I don't use filter groups, all four filters (Capture 6.jpg) in the same group with OR or AND. Then I can use pagers but naturally, the result views page don't behave correctly and fulfill what i try to accomplish.

EDIT: The same thing happens with today 24/03/2011 dev

dawehner’s picture

Status: Active » Needs review
FileSize
1.5 KB

Thanks for testing.

This patch fixes the issue for me. Please test it.

EndEd’s picture

FileSize
145.04 KB
14.44 KB

Sorry for the delay and thanks for your patience. Yes the patch now remove the errors in the views UI but I noticed two things.

1. If i click the 'Reduce duplicates' on any or both taxonomy exposed filter to remove the option (see first post->Capture 5.jpg) and i try the views page and use the taxonomy exposed filter in any way i get (see this post->error.jpg).

2. Also i get a weird behavior if I try this:

Suppose I have a vocabulary with hierarchical terms like this (see this post->vocabulary.jpg). What I´m trying to do is using the previous posts views example, creating the two taxonomy exposed filters using only the 'subterms' terms (see this post->vocabulary.jpg). So the first Taxonomy exposed filter (lets called exposed1) have selected all the subterms childs of term1 (subterm1, subterm2 & subterm3) and the second Taxonomy exposed filter (lets called exposed2) have selected or the subterms childs of term2 (subterm4, subterm5 & subterm6).

In order to do that i have selected in both Taxonomy Exposed filters the 'Limit list to select items' option (see first post->Capture 5.jpg).

The problem when i try the view page and try to filter with exposed1 & exposed2 & those subterms I get this:

(take in account every subterm should give me 3 different results (nodes)).

  • I filter using subterm1 (exposed1) = Correct (3 Results)
  • I filter using subterm1 (exposed1) and subterm4 (exposed2) = Correct (6 Results, 3 from subterm1 & 3 from subterm4)
  • I filter using subterm1 (exposed1) and subterm3 (exposed1) = No Results and thats the problem. It suppose to give me 6 Results, 3 from subterm1 and 3 from subterm3. The same happens if I try to filter using only 2 or more subterms from exposed2, I get no results

Is this behavior correct? Am I doing something wrong or not taking something on account?

dawehner’s picture

Status: Needs review » Needs work

Okay so this still needs work...

Just my 2cents: OH TAXONOMY.

EndEd’s picture

Indeed :)

dawehner’s picture

Thanks for testing.
Okay commited the patch which fixed the errors,
but there are still additional bugs reported in #4

David_Rothstein’s picture

Status: Needs work » Needs review
FileSize
417 bytes

I've hit a similar problem as the error.png screenshot shown in #4, under very similar conditions (though not exactly the same).

The attached patch fixes it for me. The full context is this:

    // Shorten some variables:
    $field = $this->get_field();
    $options = $this->handler->options;
    $operator = $this->handler->operator;
    $formula = !empty($this->formula);
    $value = $this->handler->value;
    if (empty($options['group'])) {
      $options['group'] = 0;
    }
    else {
      $value = $this->handler->value;
      $operator = 'IN';
    }

The "else" statement (which the attached patch removes) is what seems problematic:
(1) Setting $value is unnecessary since it was already set above.
(2) Setting $operator to 'IN' overrides the actual operator, and therefore bypasses code below this that checks, e.g., for cases where $operator is 'or' and runs specific logic based on that.

Does that makes sense?

dawehner’s picture

FileSize
1.07 KB

The change was part of http://drupal.org/node/1023794 and the patch was applied totally false.
So here is a change with some additional cleanup on top: change $this-handler->value to $value everywhere.

This code is really ugly.
Note: Before commit this someone would have to look at the d6 version and see how it's there.

David_Rothstein’s picture

     elseif ($operator == 'or' && empty($options['reduce_duplicates'])) {
-      if (count($this->handler->value) > 1) {
-        $value = $this->handler->value;
+      if (count($value) > 1) {
         $operator = 'IN';
       }
       else {
-        $value = is_array($this->handler->value) ? array_pop($this->handler->value) : $this->handler->value;
+        $value = is_array($value) ? array_pop($value) : $value;
         $operator = '=';
       }
       $add_condition = FALSE;
     }
+    else {
+      $operator = 'IN';
+    }

The last part of the patch doesn't look right to me on a first glance... Because what happens if $operator starts off as 'or' and $options['reduce_duplicates'] is TRUE?

Then, this code will wind up switching the 'or' to 'IN'. But further down, the code does this:

$clause = $operator == 'or' ? db_or() : db_and();

so the end result will be that we started off with 'or' but wind up using db_and() in the query. I'm guessing that's wrong?

Note: Before commit this someone would have to look at the d6 version and see how it's there.

Here's a handy link: http://drupalcode.org/project/views.git/blob/refs/heads/6.x-3.x:/include...

I think it's consistent with not having to force the operator to 'IN' in D7, but I haven't studied it closely enough to be sure.

dawehner’s picture

You are right.

This previous issue was basically just a 100% wrong commit.
The initial bug of the other issue was fixed with #955464: Missing join: 'taxonomy_term_data' creating a Glossary view based on taxonomy

So it's safe and just apply the patch in #8. Commited to 7.x

Here is a cleanup for the variable names and some documentation.

David_Rothstein’s picture

Status: Needs review » Reviewed & tested by the community

I didn't actually test it, but that followup patch certainly looks good to me...

dawehner’s picture

Status: Reviewed & tested by the community » Fixed

Commited to 7.x
Thanks for the quick look up.

Status: Fixed » Closed (fixed)

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