Hi,
The exposed filter Content : has taxonomy terms (with depth) seems to be broken. [EDIT : does not bring back unpublished nodes.]
Steps to reproduce:
Create a Vocabulary with at least two levels as such :
Parent 1
Parent 2
- Child 2.1
- Child 2.2
Parent 3
Assuming that:
- Some nodes can be directly referencing parent terms like "Parent 1" or "Parent 3".
- Some nodes can be directly referencing Children terms like "Child 2.1"
- There cannot be nodes referencing parent terms that have children terms. Ex : there cannot be nodes referencing "Parent 2".
- The Exposed Filter is of type Content : has taxonomy terms (with depth) using a depth value of 1.
Expected behavior:
If the exposed filter is set to "Parent 1", all/only nodes referencing "Parent 1" should be retrieved
If the exposed filter is set to "Child 2.1" all/only nodes referencing "Child 2.1" should be retrieved
If the exposed filter is set to "Parent 2" all/only nodes referencing "Child 2.1" and also "Child 2.2" should be retrieved
Actual behavior:
- Leaving the exposed filter to "- Any -" brings back all results as expected
- Choosing any other value of any level brings back no results.
I actually tried on several Drupal installations with different versions of Views installed.
Is this working for anyone?
EDIT [ #4
Found it! The bug happens when you try to display unpublished nodes only.
On a clean install, follow the steps on #1 and finally add a filter Content : Published (No).
Obviously you also need to unpublish your nodes...
]
Comments
Comment #1
Mołot commented"not working at all for me" is very vague term that makes it quite impossible to help here.
Could you describe experienced behavior just the way you described expected one? Or do you simply meant that filtering is ignored and you always get all nodes anyway?
And maybe include sample data and exported view that, imported to a clean Druapl+Views installation, allows to recreate your bug?
For me filtering by taxonomy always worked quite as expected.
Comment #2
nicolas bouteille commentedSorry. Edited my first post to add the Actual behavior. Will now see if I can reproduce this on a clean Drupal + Views install.
Comment #3
nicolas bouteille commentedOk it works on a clean install... sorry for calling this a bug report. Switching back to support request.
What info could I provide you with so that you could help me find out what's wrong in my config and causing this not to work?
Comment #4
nicolas bouteille commentedFound it! The bug happens when you try to display unpublished nodes only.
On a clean install, follow the steps on #1 and finally add a filter Content : Published (No).
Obviously you also need to unpublish your nodes...
Comment #5
Mołot commentedCongratulations :)
So long story short unpublished nodes are treated like not belonging to any taxonomy term there?
Comment #6
nicolas bouteille commentedYes. But it works for simple taxonomy exposed filters. Only not working with filters with depth.
Updating title.
Comment #7
Mołot commentedWill see if I can patch this easily. Shouldn't be hard when we have a comparison.
Could you paste the very SQL? With -Any- and with selection? That would make it easief for me to find that part of code (I'm not a part of viwews team, you know, just a one who happened to need them bug-free)
Edit: OK, forget it, views_handler_filter_term_node_tid_depth.inc
But I can't see any point that would refer to published nodes or unpublished ones. So I guess I'd really like to see your SQLs anyway. And what SQL engine and version you are using? If MySQL, are your table MyISAM, InnoDB or mox of those? Only joins added for depth are around line 80 to 95, and they are simple and reasonable. And seems to work for me.
Or maybe current GIT version works already? Consider $ git clone --recursive --branch 7.x-3.x http://git.drupal.org/project/views.git
Comment #8
nicolas bouteille commentedHere is the SQL generated when - Any - is selected. All nodes even unpublished are brought back.
Here is the SQL generated when a Parent term with children is selected or when a Child term is selected (the SQL is the same). Unpublished nodes are forgotten.
I am using a MySQL database with innoDB tables.
For the last part I don't know how to use Git yet :(
Comment #9
Mołot commentedHow to use GIT: On linux: install it, open console, cd to your modules directory and just paste the command (without $, $ means it's a shell command of a non-root user). On windows install http://msysgit.github.io/ run GitBASH and do the same ;) and then consider git-aware IDE (NetBeans, Eclipse, Zend, whatever)
And your problem seems not views-related, http://drupal.org/node/962664 this issue shows it's bug in core - unpublished nodes are simply ignored by functions that operate on {taxonomy_index} and it seems it's by design.
Comment #10
Mołot commentedSeems you need to write your own argumen handler for now. One that will use field directly, without the index table.
You can pretty much steal code from views_handler_filter_term_node_tid_depth.inc to do it, just wrap it in a module.
Comment #11
nicolas bouteille commentedThank you for your great help.
This is starting to be a bit difficult for me but I'm sure I will understand it in the end :)
Comment #12
Mołot commentedI still think there is an irritating inconsistency. Taxonomy uses {taxonomy_index} as an cache for published nodes only. Views use this table as an taxonomy-node join table, no matter pubilshed or not. Taxonomy team claims it's views bug, view guys claim it's taxonomy's problem.
Why can't they cooperate and either stop using this table in views or start filling it for all nodes in taxonomy? I expected more from Drupal teams.
Comment #13
gan_drupal commented@Nicolas - Thanks. Actually I'm also trying to get the same behavior. But not able to get the below expected behavior:
"If the exposed filter is set to "Parent 2" all/only nodes referencing "Child 2.1" and also "Child 2.2" should be retrieved"
Meant, if i select Parent 2, my result out of it is nothing.
How do i get this using Views + Drupal 6 ? Can anyone help on this ?
Comment #14
nicolas bouteille commentedthis post was not related to the original problem and has been moved here https://drupal.org/node/2116645
Comment #15
gan_drupal commentedThanks a lot @Nicolas. I got it now.
What i was trying now is, when i click the checkbox of parent 2.1 and hit on search button i got the expected result, when i try to search for parent 2.2 also i got the result.
Now what i need is, when i click on parent 2, i got the result with both parent 2.1 and 2.2, but the checkboxes are not checked for parent 2.1 and 2.2.
I want both the checkboxes to be checked when i click on parent 2 for search. In the same way, if i check both parent 2.1 and parent 2.2, then parent 2 should also be checked automatically. Is it possible ? please advice.
Comment #15.0
gan_drupal commentedAdded Actual behavior
Comment #16
nicolas bouteille commentedOk I created a new issue for your request and I will delete my previous post so that this issue remains related to its original problem.
https://drupal.org/node/2116645
Comment #17
gan_drupal commentedAnyway thanks for your advice @Nicolas. Much Appreciated !!!
Comment #17.0
gan_drupal commentedadding info on the real problem
Comment #18
rimibhagat commentedThis Issue still persists with Drupal 8 too.
On unpublished content the taxonomy filter of "has taxonomy with depth" doesn't work.
Any Update on this?