Hello,

Strange bug was found when I tried to create quite basic Taxonomy Term view with filter by selected taxonomy terms.

Here's view settings page: http://i.imgur.com/hXnAX.png

Here's screen with some terms selected for filter: http://i.imgur.com/LMeH8.png

Here's error message:

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'taxonomy_term_data.nid' in 'IN/ALL/ANY subquery'

Here's query:

SELECT taxonomy_term_data.name AS taxonomy_term_data_name, taxonomy_term_data.vid AS taxonomy_term_data_vid, taxonomy_term_data.tid AS tid, taxonomy_vocabulary.machine_name AS taxonomy_vocabulary_machine_name
FROM 
{taxonomy_term_data} taxonomy_term_data
LEFT JOIN {taxonomy_vocabulary} taxonomy_vocabulary ON taxonomy_term_data.vid = taxonomy_vocabulary.vid
WHERE (( (taxonomy_vocabulary.machine_name IN  ('categories')) AND (taxonomy_term_data.nid IN  (SELECT tn.nid AS nid
FROM 
{taxonomy_index} tn
WHERE  (tn.tid IN  ('72', '58', '59', '75')) )) ))

May be issue caused by line 436 of views_handler_filter_term_node_tid.inc file:

432      $subquery = db_select('taxonomy_index', 'tn');
433      $subquery->addField('tn', 'nid');
434      $last = 'tn';
435      $subquery->condition('tn.tid', $tid, $operator);
436      $this->query->add_where($this->options['group'], "$this->table_alias.nid", $subquery, 'IN');

Could you please advice?

Thanks!

Comments

yurg’s picture

Just in case someone interested: I made code modification (taxonomy_index in query was replaced by taxonomy_term_data), so now filter works as expected.

432   $subquery = db_select('taxonomy_term_data', 'td');
433   $subquery->addField('td', 'tid');
434   $last = 'tn';
435   $subquery->condition('td.tid', $tid, $operator);
436   $this->query->add_where($this->options['group'], "$this->table_alias.tid", $subquery, 'IN');

Not sure if patch should be made since have no idea about any unintended consequences caused by code changes.

yurg’s picture

Status: Active » Closed (outdated)