Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
When using an exposed filter on a term, that has a relation to a configured vocabulary. The views query is broken.
I filter on term id 4:
As admin, following query is constructed:
SELECT DISTINCT node.title AS node_title, node.nid AS nid, node.type AS node_type, users_node.name AS users_node_name, users_node.uid AS users_node_uid, node.changed AS node_changed, 'node' AS field_data_field_article_category_node_entity_type FROM node node LEFT JOIN (SELECT td.*, tn.nid AS nid FROM taxonomy_term_data td LEFT JOIN taxonomy_vocabulary tv ON td.vid = tv.vid LEFT JOIN taxonomy_index tn ON tn.tid = td.tid WHERE (tv.machine_name IN (<strong>'category'</strong>)) ) taxonomy_term_data_node ON node.nid = taxonomy_term_data_node.nid LEFT JOIN users users_node ON node.uid = users_node.uid WHERE (( (taxonomy_term_data_node.tid = '4') )) ORDER BY node_changed DESC LIMIT 20 OFFSET 0
When doïng the same as non-admin, following thing occures:
SELECT DISTINCT node.title AS node_title, node.nid AS nid, node.type AS node_type, users_node.name AS users_node_name, users_node.uid AS users_node_uid, node.changed AS node_changed, 'node' AS field_data_field_article_category_node_entity_type FROM node node LEFT JOIN (SELECT td.*, tn.nid AS nid FROM taxonomy_term_data td LEFT JOIN taxonomy_vocabulary tv ON td.vid = tv.vid LEFT JOIN taxonomy_index tn ON tn.tid = td.tid WHERE (tv.machine_name IN (<strong>'4'</strong>)) ) taxonomy_term_data_node ON node.nid = taxonomy_term_data_node.nid LEFT JOIN users users_node ON node.uid = users_node.uid WHERE (( (taxonomy_term_data_node.tid = '4') )) ORDER BY node_changed DESC LIMIT 20 OFFSET 0
Comment | File | Size | Author |
---|---|---|---|
#5 | search_config-access_alter-1378602-5.patch | 733 bytes | nils.destoop |
#4 | search_config-access_alter-1378602-4.patch | 780 bytes | nils.destoop |
#2 | search_config-access_alter-1378602-2.patch | 853 bytes | nils.destoop |
#1 | search_config-access_alter-1378602-1.patch | 822 bytes | nils.destoop |
Comments
Comment #1
nils.destoop CreditAttribution: nils.destoop commentedIncluded is the patch. Somehow, assigning variables in the foreach messes up the query. (PHP 5.2.13)
Comment #2
nils.destoop CreditAttribution: nils.destoop commentedlittle fix in patch
Comment #3
nils.destoop CreditAttribution: nils.destoop commentedCompletely ignore my patches. :p
Comment #4
nils.destoop CreditAttribution: nils.destoop commentedNow the correct patch. Previous patches would fail if you use multiple node tables.
Problem occures when one of the tables is a subquery.
Comment #5
nils.destoop CreditAttribution: nils.destoop commentedIn patch 2 things should not be deleted.
- $search = FALSE;
- $node = FALSE;
Comment #6
nils.destoop CreditAttribution: nils.destoop commentedComment #7
Alan D. CreditAttribution: Alan D. commentedWhich version of Drupal 7 core are you using?
Comment #8
Alan D. CreditAttribution: Alan D. commentedI have tried to replicate this with the supplied information, but I could not.
The patch bypasses the apparent issue, but maybe it should be adapted to handle the change rather than ignoring it.
At minimal, I need steps like:
Create a content type and add a Term reference to a single taxonomy
Create a view of this type and assign an exposed widget that filters on this term. (I also added a Search keyword exposed form too.)
Save and search using a term from this vocabulary
Which is what I did and I had no issues
Comment #9
Alan D. CreditAttribution: Alan D. commentedAnd looking at the query, this looks like it is a bug from the core Drupal DB system that was fixed in Drupal 7.8....
Comment #10
Alan D. CreditAttribution: Alan D. commentedMarking duplicate of the core bug that was fixed years ago, whatever that was again. There are still a couple of core Drupal access bugs still unresolved too.