Adding a "Taxonomy: Vocabulary" filter to a node view adds the following SQL fragment:

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  (1)) )

tv.machine_name, though, is a string, not an int. vid is an int. We probably want to join on the string here.

CommentFileSizeAuthor
#4 942106-term-node-filter-d7.patch964 bytesandypost

Comments

dawehner’s picture

Status: Active » Postponed (maintainer needs more info)

I know you know this. It's incredible helpful to have a export of a view.

Here is one which worked for me

$view = new view;
$view->name = 'terms';
$view->description = '';
$view->tag = '';
$view->base_table = 'node';
$view->api_version = '3.0-alpha1';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */

/* Display: Defaults */
$handler = $view->new_display('default', 'Defaults', 'default');
$handler->display->display_options['access']['type'] = 'none';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['pager']['type'] = 'full';
$handler->display->display_options['style_plugin'] = 'default';
$handler->display->display_options['row_plugin'] = 'fields';
/* Field: Node: Nid */
$handler->display->display_options['fields']['nid']['id'] = 'nid';
$handler->display->display_options['fields']['nid']['table'] = 'node';
$handler->display->display_options['fields']['nid']['field'] = 'nid';
$handler->display->display_options['fields']['nid']['alter']['alter_text'] = 0;
$handler->display->display_options['fields']['nid']['alter']['make_link'] = 0;
$handler->display->display_options['fields']['nid']['alter']['absolute'] = 0;
$handler->display->display_options['fields']['nid']['alter']['trim'] = 0;
$handler->display->display_options['fields']['nid']['alter']['word_boundary'] = 1;
$handler->display->display_options['fields']['nid']['alter']['ellipsis'] = 1;
$handler->display->display_options['fields']['nid']['alter']['strip_tags'] = 0;
$handler->display->display_options['fields']['nid']['alter']['html'] = 0;
$handler->display->display_options['fields']['nid']['hide_empty'] = 0;
$handler->display->display_options['fields']['nid']['empty_zero'] = 0;
$handler->display->display_options['fields']['nid']['link_to_node'] = 0;
/* Filter: Taxonomy: Vocabulary */
$handler->display->display_options['filters']['vid']['id'] = 'vid';
$handler->display->display_options['filters']['vid']['table'] = 'taxonomy_term_data';
$handler->display->display_options['filters']['vid']['field'] = 'vid';
$handler->display->display_options['filters']['vid']['value'] = array(
  '1' => '1',
);

Sadly i have no idea how to reproduce it.

esmerel’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)
andypost’s picture

Status: Closed (cannot reproduce) » Needs work

Reopening because if views has been created before taxonomy patch for machine names there's no ability to remove old options['vid'] so new settings can't be saved. Suppose we should make hook_update_N() to update all views for new options['vocabulary'] and remove support for legacy option.

Also this approach should be used in upgrade path from D6.2

views_handler_filter_term_node_tid.inc


    // Convert legacy vid option to machine name vocabulary.
    if (!empty($this->options['vid'])) {
      $vocabularies = taxonomy_get_vocabularies();
      $vid = $this->options['vid'];
      if (isset($vocabularies[$vid], $vocabularies[$vid]->machine_name)) {
        $this->options['vocabulary'] = $vocabularies[$vid]->machine_name;
      }
    }
andypost’s picture

Assigned: Unassigned » andypost
Priority: Normal » Critical
Status: Needs work » Needs review
StatusFileSize
new964 bytes

This should be fixed ASAP

EDIT No reason to refer an old option setting if there are new one.
also this could a bit improve performance.

dawehner’s picture

Status: Needs review » Fixed

Thanks!

Status: Fixed » Closed (fixed)

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