? PATCHES.txt
? d7_views_taxonomy_handlers.patch
Index: views.info
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/views/views.info,v
retrieving revision 1.7.6.35
diff -u -p -r1.7.6.35 views.info
--- views.info	23 Aug 2010 14:09:58 -0000	1.7.6.35
+++ views.info	20 Sep 2010 19:36:53 -0000
@@ -178,6 +178,7 @@ files[] = modules/taxonomy/views_handler
 files[] = modules/taxonomy/views_handler_filter_term_node_tid.inc
 files[] = modules/taxonomy/views_handler_filter_term_node_tid_depth.inc
 files[] = modules/taxonomy/views_handler_filter_vocabulary_vid.inc
+files[] = modules/taxonomy/views_handler_filter_vocabulary_machine_name.inc
 files[] = modules/taxonomy/views_handler_relationship_node_term_data.inc
 files[] = modules/taxonomy/views_plugin_argument_validate_taxonomy_term.inc
 files[] = modules/taxonomy/views_plugin_argument_default_taxonomy_tid.inc
Index: modules/taxonomy.views.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/views/modules/taxonomy.views.inc,v
retrieving revision 1.57.4.13
diff -u -p -r1.57.4.13 taxonomy.views.inc
--- modules/taxonomy.views.inc	23 Aug 2010 10:20:21 -0000	1.57.4.13
+++ modules/taxonomy.views.inc	20 Sep 2010 19:36:53 -0000
@@ -57,6 +57,10 @@ function taxonomy_views_data() {
       'handler' => 'views_handler_field',
       'click sortable' => TRUE,
     ),
+    'filter' => array(
+      'help' => t('Filter the results of "Taxonomy: Term" to a particular vocabulary.'),
+      'handler' => 'views_handler_filter_vocabulary_machine_name',
+    ),
   );
   $data['taxonomy_vocabulary']['vid'] = array(
     'title' => t('Vocabulary ID'), // The item it appears as on the UI,
@@ -89,6 +93,10 @@ function taxonomy_views_data() {
       'left_field' => 'tid',
       'field' => 'tid',
     ),
+    'taxonomy_vocabulary' => array(
+      'field' => 'vid',
+      'left_field' => 'vid',
+    ),
     // This is provided for many_to_one argument
     'taxonomy_index' => array(
       'field' => 'tid',
Index: modules/taxonomy/views_handler_argument_term_node_tid.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/views/modules/taxonomy/views_handler_argument_term_node_tid.inc,v
retrieving revision 1.1.6.3
diff -u -p -r1.1.6.3 views_handler_argument_term_node_tid.inc
--- modules/taxonomy/views_handler_argument_term_node_tid.inc	16 Aug 2010 20:53:39 -0000	1.1.6.3
+++ modules/taxonomy/views_handler_argument_term_node_tid.inc	20 Sep 2010 19:36:53 -0000
@@ -7,7 +7,6 @@ class views_handler_argument_term_node_t
   function option_definition() {
     $options = parent::option_definition();
     $options['set_breadcrumb'] = array('default' => FALSE);
-    $options['use_synonym_for_summary_links'] = array('default' => FALSE);
     return $options;
   }
 
@@ -19,12 +18,6 @@ class views_handler_argument_term_node_t
       '#description' => t('If selected, the breadcrumb trail will include all parent terms, each one linking to this view. Note that this only works if just one term was received.'),
       '#default_value' => !empty($this->options['set_breadcrumb']),
     );
-    $form['use_synonym_for_summary_links'] = array(
-      '#type' => 'checkbox',
-      '#title' => t('Use term synonyms for summary links'),
-      '#description' => t('If selected, summary views will use a synonym defined for each term when creating the URL to link to that term. Note that this only works reliably if terms have at most one synonym.'),
-      '#default_value' => !empty($this->options['use_synonym_for_summary_links']),
-    );
   }
 
   function set_breadcrumb(&$breadcrumb) {
@@ -37,23 +30,12 @@ class views_handler_argument_term_node_t
 
   function title_query() {
     $titles = array();
-
-    $result = db_query("SELECT name FROM {taxonomy_term_data} WHERE tid IN (:tids)", array(':tids' => $this->value));
+    $result = db_select('taxonomy_term_data', 'td')
+      ->fields('td', array('name'))
+      ->condition('td.tid', $this->value);
     foreach ($result as $term) {
       $titles[] = check_plain($term->name);
     }
     return $titles;
   }
-
-  function summary_argument($data) {
-    if (!empty($this->options['use_synonym_for_summary_links'])) {
-      $synonym = db_query_range("SELECT name FROM {taxonomy_term_synonym} WHERE tid = %d", $data->{$this->base_alias}, 0, 1)->fetchField();
-      if (!empty($synonym)) {
-        return $synonym;
-      }
-    }
-    return $data->{$this->base_alias};
-  }
-
 }
-
Index: modules/taxonomy/views_handler_field_term_node_tid.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/views/modules/taxonomy/views_handler_field_term_node_tid.inc,v
retrieving revision 1.4.4.3
diff -u -p -r1.4.4.3 views_handler_field_term_node_tid.inc
--- modules/taxonomy/views_handler_field_term_node_tid.inc	26 Aug 2010 09:41:55 -0000	1.4.4.3
+++ modules/taxonomy/views_handler_field_term_node_tid.inc	20 Sep 2010 19:36:53 -0000
@@ -13,6 +13,16 @@ class views_handler_field_term_node_tid 
     else {
       $this->additional_fields['vid'] = array('table' => 'node', 'field' => 'vid');
     }
+
+    // Convert legacy vids option to machine name vocabularies.
+    if (!empty($this->options['vids'])) {
+      $vocabularies = taxonomy_get_vocabularies();
+      foreach ($this->options['vids'] as $vid) {
+        if (isset($vocabularies[$vid], $vocabularies[$vid]->machine_name)) {
+          $this->options['vocabularies'][$vocabularies[$vid]->machine_name] = $vocabularies[$vid]->machine_name;
+        }
+      }
+    }
   }
 
   function option_definition() {
@@ -20,7 +30,7 @@ class views_handler_field_term_node_tid 
 
     $options['link_to_taxonomy'] = array('default' => TRUE);
     $options['limit'] = array('default' => FALSE);
-    $options['vids'] = array('default' => array());
+    $options['vocabularies'] = array('default' => array());
 
     return $options;
   }
@@ -45,16 +55,16 @@ class views_handler_field_term_node_tid 
     $options = array();
     $vocabularies = taxonomy_get_vocabularies();
     foreach ($vocabularies as $voc) {
-      $options[$voc->vid] = check_plain($voc->name);
+      $options[$voc->machine_name] = check_plain($voc->name);
     }
 
-    $form['vids'] = array(
-      '#prefix' => '<div><div id="edit-options-vids">',
+    $form['vocabularies'] = array(
+      '#prefix' => '<div><div id="edit-options-vocabularies">',
       '#suffix' => '</div></div>',
       '#type' => 'checkboxes',
       '#title' => t('Vocabularies'),
       '#options' => $options,
-      '#default_value' => $this->options['vids'],
+      '#default_value' => $this->options['vocabularies'],
       '#process' => array('form_process_checkboxes', 'views_process_dependency'),
       '#dependency' => array('edit-options-limit' => array(TRUE)),
     );
@@ -77,17 +87,25 @@ class views_handler_field_term_node_tid 
     }
 
     if ($vids) {
-      $voc = '';
-      if (!empty($this->options['limit']) && !empty($this->options['vids'])) {
-        $voc = " AND td.vid IN (" . implode(', ', array_keys(array_filter($this->options['vids']))) . ")";
+      $query = db_select('taxonomy_term_data', 'td');
+      $query->innerJoin('taxonomy_index', 'tn', 'td.tid = tn.tid');
+      $query->innerJoin('taxonomy_vocabulary', 'tv', 'td.vid = tv.vid');
+      $query->fields('td');
+      $query->addField('tn', 'nid', 'node_vid');
+      $query->addField('tv', 'name', 'vocabulary');
+      $query->addField('tv', 'machine_name', 'vocabulary_machine_name');
+      $query->orderby('td.weight');
+      $query->orderby('td.name');
+      $query->condition('tn.nid', $vids);
+      if (!empty($this->options['limit']) && !empty($this->options['vocabularies'])) {
+        $query->condition('tv.machine_name', $this->options['vocabularies']);
       }
-
-      $result = db_query("SELECT tn.nid AS node_vid, td.*, v.name as vocabulary FROM {taxonomy_term_data} td INNER JOIN {taxonomy_index} tn ON td.tid = tn.tid INNER JOIN {taxonomy_vocabulary} v ON v.vid = td.vid WHERE tn.nid IN (" . implode(', ', $vids) . ")$voc ORDER BY td.weight, td.name");
+      $result = $query->execute();
 
       foreach ($result as $term) {
         $this->items[$term->node_vid][$term->tid]['name'] = check_plain($term->name);
         $this->items[$term->node_vid][$term->tid]['tid'] = $term->tid;
-        $this->items[$term->node_vid][$term->tid]['vid'] = $term->vid;
+        $this->items[$term->node_vid][$term->tid]['vocabulary_machine_name'] = check_plain($term->vocabulary_machine_name);
         $this->items[$term->node_vid][$term->tid]['vocabulary'] = check_plain($term->vocabulary);
 
         if (!empty($this->options['link_to_taxonomy'])) {
@@ -105,14 +123,14 @@ class views_handler_field_term_node_tid 
   function document_self_tokens(&$tokens) {
     $tokens['[' . $this->options['id'] . '-tid' . ']'] = t('The taxonomy term ID for the term.');
     $tokens['[' . $this->options['id'] . '-name' . ']'] = t('The taxonomy term name for the term.');
-    $tokens['[' . $this->options['id'] . '-vid' . ']'] = t('The vocabulary ID for the vocabulary the term belongs to.');
+    $tokens['[' . $this->options['id'] . '-vocabulary-machine-name' . ']'] = t('The machine name for the vocabulary the term belongs to.');
     $tokens['[' . $this->options['id'] . '-vocabulary' . ']'] = t('The name for the vocabulary the term belongs to.');
   }
 
   function add_self_tokens(&$tokens, $item) {
     $tokens['[' . $this->options['id'] . '-tid' . ']'] = $item['tid'];
     $tokens['[' . $this->options['id'] . '-name' . ']'] = $item['name'];
-    $tokens['[' . $this->options['id'] . '-vid' . ']'] = $item['vid'];
+    $tokens['[' . $this->options['id'] . '-vocabulary-machine-name' . ']'] = $item['vid'];
     $tokens['[' . $this->options['id'] . '-vocabulary' . ']'] = $item['vocabulary'];
   }
 }
Index: modules/taxonomy/views_handler_filter_term_node_tid.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/views/modules/taxonomy/views_handler_filter_term_node_tid.inc,v
retrieving revision 1.8.6.7
diff -u -p -r1.8.6.7 views_handler_filter_term_node_tid.inc
--- modules/taxonomy/views_handler_filter_term_node_tid.inc	26 Aug 2010 09:41:55 -0000	1.8.6.7
+++ modules/taxonomy/views_handler_filter_term_node_tid.inc	20 Sep 2010 19:36:53 -0000
@@ -5,6 +5,19 @@
  * Filter by term id
  */
 class views_handler_filter_term_node_tid extends views_handler_filter_many_to_one {
+  function init(&$view, &$options) {
+    parent::init($view, $options);
+
+    // 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;
+      }
+    }
+  }
+
   function has_extra_options() { return TRUE; }
 
   function get_value_options() { /* don't overwrite the value options */ }
@@ -14,7 +27,7 @@ class views_handler_filter_term_node_tid
 
     $options['type'] = array('default' => 'textfield');
     $options['limit'] = array('default' => TRUE);
-    $options['vid'] = array('default' => 0);
+    $options['vocabulary'] = array('default' => 0);
     $options['hierarchy'] = array('default' => 0);
     $options['error_message'] = array('default' => TRUE);
 
@@ -24,7 +37,7 @@ class views_handler_filter_term_node_tid
   function extra_options_form(&$form, &$form_state) {
     $vocabularies = taxonomy_get_vocabularies();
     foreach ($vocabularies as $voc) {
-      $options[$voc->vid] = check_plain($voc->name);
+      $options[$voc->machine_name] = check_plain($voc->name);
     }
 
     if ($this->options['limit']) {
@@ -34,14 +47,14 @@ class views_handler_filter_term_node_tid
         $this->options['vid'] = $first_vocabulary->vid;
       }
 
-      $form['vid'] = array(
+      $form['vocabulary'] = array(
         '#prefix' => '<div class="views-left-40">',
         '#suffix' => '</div>',
         '#type' => 'radios',
         '#title' => t('Vocabulary'),
         '#options' => $options,
         '#description' => t('Select which vocabulary to show terms for in the regular options.'),
-        '#default_value' => $this->options['vid'],
+        '#default_value' => $this->options['vocabulary'],
       );
     }
 
@@ -70,7 +83,7 @@ class views_handler_filter_term_node_tid
   }
 
   function value_form(&$form, &$form_state) {
-    $vocabulary = taxonomy_vocabulary_load($this->options['vid']);
+    $vocabulary = taxonomy_vocabulary_machine_name_load($this->options['vocabulary']);
     if (empty($vocabulary) && $this->options['limit']) {
       $form['markup'] = array(
         '#markup' => '<div class="form-item">' . t('An invalid vocabulary is selected. Please change it in the options.') . '</div>',
@@ -81,8 +94,10 @@ class views_handler_filter_term_node_tid
     if ($this->options['type'] == 'textfield') {
       $default = '';
       if ($this->value) {
-        $result = db_query("SELECT * FROM {taxonomy_term_data} td WHERE td.tid IN (:tids)", array(
-          ':tids' => $this->value));
+        $result = db_select('taxonomy_term_data', 'td')
+          ->fields('td')
+          ->condition('td.tid', $this->value)
+          ->execute();
         foreach ($result as $term) {
           if ($default) {
             $default .= ', ';
@@ -116,12 +131,17 @@ class views_handler_filter_term_node_tid
       }
       else {
         $options = array();
+        $query = db_select('taxonomy_term_data', 'td');
+        $query->innerJoin('taxonomy_vocabulary', 'tv', 'td.vid = tv.vid');
+        $query->fields('td');
+        $query->orderby('tv.weight');
+        $query->orderby('tv.name');
+        $query->orderby('td.weight');
+        $query->orderby('td.name');
         if ($this->options['limit']) {
-          $result = db_query("SELECT * FROM {taxonomy_term_data} WHERE vid = :vid ORDER BY weight, name", array(':vid' => $vocabulary->vid));
-        }
-        else {
-          $result = db_query("SELECT td.* FROM {taxonomy_term_data} td INNER JOIN {taxonomy_vocabulary} v ON td.vid = v.vid ORDER BY v.weight, v.name, td.weight, td.name");
+          $query->condition('tv.machine_name', $vocabulary->machine_name);
         }
+        $result = $query->execute();
         foreach ($result as $term) {
           $options[$term->tid] = $term->name;
         }
@@ -260,12 +280,12 @@ class views_handler_filter_term_node_tid
       return;
     }
 
-    //$result = db_query("SELECT * FROM {taxonomy_term_data} WHERE name IN (" . implode(', ', $placeholders) . ") AND vid = %d", $args);
-    $result = db_query("SELECT * FROM {taxonomy_term_data} WHERE name IN (:name) AND vid = :vid",
-      array(
-        ':vid' => $this->options['vid'],
-        ':name' => $names
-      ));
+    $query = db_select('taxonomy_term_data', 'td');
+    $query->addJoin('taxonomy_vocabulary', 'tv', 'td.vid = tv.vid');
+    $query->fields('td');
+    $query->condition('td.name', $names);
+    $query->condition('tv.machine_name', $this->options['vocabulary']);
+    $result = $query->execute();
     foreach ($result as $term) {
       unset($missing[strtolower($term->name)]);
       $tids[] = $term->tid;
@@ -302,8 +322,10 @@ class views_handler_filter_term_node_tid
     $this->value_options = array();
 
     if ($this->value) {
-      $result = db_query("SELECT * FROM {taxonomy_term_data} td WHERE td.tid IN (:tids)", array(':tids' => $this->value));
-
+      $result = db_select('taxonomy_term_data', 'td')
+        ->fields('td')
+        ->condition('td.tid', $this->value)
+        ->execute();
       foreach ($result as $term) {
         $this->value_options[$term->tid] = $term->name;
       }
Index: modules/taxonomy/views_handler_filter_vocabulary_machine_name.inc
===================================================================
RCS file: modules/taxonomy/views_handler_filter_vocabulary_machine_name.inc
diff -N modules/taxonomy/views_handler_filter_vocabulary_machine_name.inc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ modules/taxonomy/views_handler_filter_vocabulary_machine_name.inc	20 Sep 2010 19:36:53 -0000
@@ -0,0 +1,19 @@
+<?php
+// $Id$
+
+/**
+ * Filter by vocabulary machine name
+ */
+class views_handler_filter_vocabulary_machine_name extends views_handler_filter_in_operator {
+  function get_value_options() {
+    if (isset($this->value_options)) {
+      return;
+    }
+
+    $this->value_options = array();
+    $vocabularies = taxonomy_get_vocabularies();
+    foreach ($vocabularies as $voc) {
+      $this->value_options[$voc->machine_name] = $voc->name;
+    }
+  }
+}
Index: modules/taxonomy/views_handler_relationship_node_term_data.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/views/modules/taxonomy/views_handler_relationship_node_term_data.inc,v
retrieving revision 1.3.4.2
diff -u -p -r1.3.4.2 views_handler_relationship_node_term_data.inc
--- modules/taxonomy/views_handler_relationship_node_term_data.inc	16 Aug 2010 20:53:39 -0000	1.3.4.2
+++ modules/taxonomy/views_handler_relationship_node_term_data.inc	20 Sep 2010 19:36:53 -0000
@@ -6,9 +6,23 @@
  */
 
 class views_handler_relationship_node_term_data extends views_handler_relationship  {
+  function init(&$view, &$options) {
+    parent::init($view, $options);
+
+    // Convert legacy vids option to machine name vocabularies.
+    if (!empty($this->options['vids'])) {
+      $vocabularies = taxonomy_get_vocabularies();
+      foreach ($this->options['vids'] as $vid) {
+        if (isset($vocabularies[$vid], $vocabularies[$vid]->machine_name)) {
+          $this->options['vocabularies'][$vocabularies[$vid]->machine_name] = $vocabularies[$vid]->machine_name;
+        }
+      }
+    }
+  }
+
   function option_definition() {
     $options = parent::option_definition();
-    $options['vids'] = array('default' => array());
+    $options['vocabularies'] = array('default' => array());
     return $options;
   }
 
@@ -21,14 +35,14 @@ class views_handler_relationship_node_te
     $vocabularies = taxonomy_get_vocabularies();
     $options = array();
     foreach ($vocabularies as $voc) {
-      $options[$voc->vid] = check_plain($voc->name);
+      $options[$voc->machine_name] = check_plain($voc->name);
     }
 
-    $form['vids'] = array(
+    $form['vocabularies'] = array(
       '#type' => 'checkboxes',
       '#title' => t('Vocabularies'),
       '#options' => $options,
-      '#default_value' => $this->options['vids'],
+      '#default_value' => $this->options['vocabularies'],
       '#description' => t('Choose which vocabularies you wish to relate. Remember that every term found will create a new record, so this relationship is best used on just one vocabulary that has only one term per node.'),
     );
   }
@@ -42,23 +56,27 @@ class views_handler_relationship_node_te
     $def = $this->definition;
     $def['table'] = 'taxonomy_term_data';
 
-    if (!empty($this->options['required']) || !array_filter($this->options['vids'])) {
+    if (!array_filter($this->options['vocabularies'])) {
       $term_node = $this->query->add_table('taxonomy_index', $this->relationship);
       $def['left_table'] = 'taxonomy_index';
       $def['left_field'] = 'tid';
       $def['field'] = 'tid';
-      if (!empty($this->options['required'])) {
-        $def['type'] = 'INNER';
-      }
+      $def['type'] = empty($this->options['required']) ? 'LEFT' : 'INNER';
     }
     else {
-      // If the join is optional, join a subselect that will emulate taxonomy_term_data table instead
+      // If vocabularies are supplied join a subselect instead
       $def['left_table'] = $this->table_alias;
-      $def['left_field'] = 'vid';
-      $def['field'] = 'revision';
-      // fapi ensures vids are safe here.
-      $vids = implode(', ', array_filter($this->options['vids']));
-      $def['table formula'] = "(SELECT td.*, tn.vid AS revision FROM {taxonomy_term_data} td INNER JOIN {taxonomy_index} tn ON tn.tid = td.tid WHERE td.vid IN ($vids))";
+      $def['left_field'] = 'nid';
+      $def['field'] = 'nid';
+      $def['type'] = empty($this->options['required']) ? 'LEFT' : 'INNER';
+
+      $query = db_select('taxonomy_term_data', 'td');
+      $query->addJoin($def['type'], 'taxonomy_vocabulary', 'tv', 'td.vid = tv.vid');
+      $query->addJoin($def['type'], 'taxonomy_index', 'tn', 'tn.tid = td.tid');
+      $query->condition('tv.machine_name', array_filter($this->options['vocabularies']));
+      $query->fields('td');
+      $query->fields('tn', array('nid'));
+      $def['table formula'] = $query;
     }
 
     $join = new views_join();
Index: modules/taxonomy/views_plugin_argument_default_taxonomy_tid.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/views/modules/taxonomy/Attic/views_plugin_argument_default_taxonomy_tid.inc,v
retrieving revision 1.1.2.4
diff -u -p -r1.1.2.4 views_plugin_argument_default_taxonomy_tid.inc
--- modules/taxonomy/views_plugin_argument_default_taxonomy_tid.inc	16 Aug 2010 20:53:39 -0000	1.1.2.4
+++ modules/taxonomy/views_plugin_argument_default_taxonomy_tid.inc	20 Sep 2010 19:36:53 -0000
@@ -6,13 +6,27 @@
  */
 
 class views_plugin_argument_default_taxonomy_tid extends views_plugin_argument_default {
+  function init(&$view, &$argument, &$options) {
+    parent::init($view, $argument, $options);
+
+    // Convert legacy vids option to machine name vocabularies.
+    if (!empty($this->options['vids'])) {
+      $vocabularies = taxonomy_get_vocabularies();
+      foreach ($this->options['vids'] as $vid) {
+        if (isset($vocabularies[$vid], $vocabularies[$vid]->machine_name)) {
+          $this->options['vocabularies'][$vocabularies[$vid]->machine_name] = $vocabularies[$vid]->machine_name;
+        }
+      }
+    }
+  }
+
   function option_definition() {
     $options = parent::option_definition();
 
     $options['term_page'] = array('default' => TRUE);
     $options['node'] = array('default' => FALSE);
     $options['limit'] = array('default' => FALSE);
-    $options['vids'] = array('default' => array());
+    $options['vocabularies'] = array('default' => array());
 
     return $options;
   }
@@ -42,16 +56,16 @@ class views_plugin_argument_default_taxo
     $options = array();
     $vocabularies = taxonomy_get_vocabularies();
     foreach ($vocabularies as $voc) {
-      $options[$voc->vid] = check_plain($voc->name);
+      $options[$voc->machine_name] = check_plain($voc->name);
     }
 
-    $form['vids'] = array(
+    $form['vocabularies'] = array(
       '#prefix' => '<div><div id="edit-options-vids">',
       '#suffix' => '</div></div>',
       '#type' => 'checkboxes',
       '#title' => t('Vocabularies'),
       '#options' => $options,
-      '#default_value' => $this->options['vids'],
+      '#default_value' => $this->options['vocabularies'],
       '#process' => array('form_process_checkboxes', 'views_process_dependency'),
       '#dependency' => array(
         //'edit-options-argument-default-taxonomy-tid-limit' => array(1),
@@ -62,7 +76,7 @@ class views_plugin_argument_default_taxo
 
   function options_submit(&$form, &$form_state, &$options) {
     // Clear checkbox values.
-    $options['vids'] = array_filter($options['vids']);
+    $options['vocabularies'] = array_filter($options['vocabularies']);
   }
 
   function get_argument() {
@@ -88,16 +102,18 @@ class views_plugin_argument_default_taxo
           $field_info = field_info_field($name);
           if ($field_info['type'] == 'taxonomy_term_reference') {
             $items = field_get_items('node', $node, $name);
-            foreach ($items as $item) {
-              $taxonomy[$item['tid']] = $item['taxonomy_term'];
+            if (is_array($items)) {
+              foreach ($items as $item) {
+                $taxonomy[$item['tid']] = $item['taxonomy_term'];
+              }
             }
           }
         }
         if (!empty($this->options['limit'])) {
           $tids = array();
-          // filter by vid
+          // filter by vocabulary
           foreach ($taxonomy as $tid => $term) {
-            if (!empty($this->options['vids'][$term->vid])) {
+            if (!empty($this->options['vocabularies'][$term->vocabulary_machine_name])) {
               $tids[] = $tid;
             }
           }
Index: modules/taxonomy/views_plugin_argument_validate_taxonomy_term.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/views/modules/taxonomy/views_plugin_argument_validate_taxonomy_term.inc,v
retrieving revision 1.6.4.6
diff -u -p -r1.6.4.6 views_plugin_argument_validate_taxonomy_term.inc
--- modules/taxonomy/views_plugin_argument_validate_taxonomy_term.inc	19 Sep 2010 10:00:20 -0000	1.6.4.6
+++ modules/taxonomy/views_plugin_argument_validate_taxonomy_term.inc	20 Sep 2010 19:36:53 -0000
@@ -9,9 +9,23 @@
  * Validate whether an argument is an acceptable node.
  */
 class views_plugin_argument_validate_taxonomy_term extends views_plugin_argument_validate {
+  function init(&$view, &$argument, &$options) {
+    parent::init($view, $argument, $options);
+
+    // Convert legacy vids option to machine name vocabularies.
+    if (!empty($this->options['vids'])) {
+      $vocabularies = taxonomy_get_vocabularies();
+      foreach ($this->options['vids'] as $vid) {
+        if (isset($vocabularies[$vid], $vocabularies[$vid]->machine_name)) {
+          $this->options['vocabularies'][$vocabularies[$vid]->machine_name] = $vocabularies[$vid]->machine_name;
+        }
+      }
+    }
+  }
+
   function option_definition() {
     $options = parent::option_definition();
-    $options['vids'] = array('default' => array());
+    $options['vocabularies'] = array('default' => array());
     $options['type'] = array('default' => 'tid');
     $options['transform'] = array('default' => FALSE);
 
@@ -22,16 +36,16 @@ class views_plugin_argument_validate_tax
     $vocabularies = taxonomy_get_vocabularies();
     $options = array();
     foreach ($vocabularies as $voc) {
-      $options[$voc->vid] = check_plain($voc->name);
+      $options[$voc->machine_name] = check_plain($voc->name);
     }
 
-    $form['vids'] = array(
+    $form['vocabularies'] = array(
       '#type' => 'checkboxes',
       '#prefix' => '<div id="edit-options-validate-argument-vocabulary-wrapper">',
       '#suffix' => '</div>',
       '#title' => t('Vocabularies'),
       '#options' => $options,
-      '#default_value' => $this->options['vids'],
+      '#default_value' => $this->options['vocabularies'],
       '#description' => t('If you wish to validate for specific vocabularies, check them; if none are checked, all terms will pass.'),
     );
 
@@ -41,8 +55,8 @@ class views_plugin_argument_validate_tax
       '#options' => array(
         'tid' => t('Term ID'),
         'tids' => t('Term IDs separated by , or +'),
-        'name' => t('Term name or synonym'),
-        'convert' => t('Term name/synonym converted to Term ID'),
+        'name' => t('Term name'),
+        'convert' => t('Term name converted to Term ID'),
       ),
       '#default_value' => $this->options['type'],
       '#description' => t('Select the form of this argument; if using term name, it is generally more efficient to convert it to a term ID and use Taxonomy: Term ID rather than Taxonomy: Term Name" as an argument.'),
@@ -57,19 +71,19 @@ class views_plugin_argument_validate_tax
 
   function options_submit(&$form, &$form_state, &$options) {
     // filter trash out of the options so we don't store giant unnecessary arrays
-    $options['vids'] = array_filter($options['vids']);
+    $options['vocabularies'] = array_filter($options['vocabularies']);
   }
 
   function convert_options(&$options) {
-    if (!isset($options['vids']) && !empty($this->argument->options['validate_argument_vocabulary'])) {
-      $options['vids'] = $this->argument->options['validate_argument_vocabulary'];
+    if (!isset($options['vocabularies']) && !empty($this->argument->options['validate_argument_vocabulary'])) {
+      $options['vocabularies'] = $this->argument->options['validate_argument_vocabulary'];
       $options['type'] = $this->argument->options['validate_argument_type'];
       $options['transform'] = isset($this->argument->options['validate_argument_transform']) ? $this->argument->options['validate_argument_transform'] : FALSE;
     }
   }
 
   function validate_argument($argument) {
-    $vids = array_filter($this->options['vids']);
+    $vocabularies = array_filter($this->options['vocabularies']);
     $type = $this->options['type'];
     $transform = $this->options['transform'];
 
@@ -79,11 +93,16 @@ class views_plugin_argument_validate_tax
           return FALSE;
         }
 
-        $result = db_query("SELECT * FROM {taxonomy_term_data} WHERE tid = :tid", array(':tid' => $argument))->fetchObject();
-        if (!$result) {
+        $query = db_select('taxonomy_term_data', 'td');
+        $query->leftJoin('taxonomy_vocabulary', 'tv', 'td.vid = tv.vid');
+        $query->fields('td');
+        $query->fields('tv', array('machine_name'));
+        $query->condition('td.tid', $argument);
+        $term = $query->execute()->fetchObject();
+        if (!$term) {
           return FALSE;
         }
-        return empty($vids) || !empty($vids[$result->vid]);
+        return empty($vocabularies) || !empty($vocabularies[$term->machine_name]);
 
       case 'tids':
         $tids = new stdClass();
@@ -112,11 +131,16 @@ class views_plugin_argument_validate_tax
 
         // if unverified tids left - verify them and cache results
         if (count($test)) {
-          $placeholders = implode(', ', array_fill(0, count($test), '%d'));
+          $query = db_select('taxonomy_term_data', 'td');
+          $query->leftJoin('taxonomy_vocabulary', 'tv', 'td.vid = tv.vid');
+          $query->fields('td');
+          $query->fields('tv', array('machine_name'));
+          $query->condition('td.tid', $test);
+
+          $result = $query->execute();
 
-          $result = db_query("SELECT * FROM {taxonomy_term_data} WHERE tid IN (:tid)", array(':tid' => $test));
           foreach ($result as $term) {
-            if ($vids && empty($vids[$term->vid])) {
+            if ($vocabularies && empty($vocabularies[$term->machine_name])) {
               $validated_cache[$term->tid] = FALSE;
               return FALSE;
             }
@@ -135,28 +159,26 @@ class views_plugin_argument_validate_tax
 
       case 'name':
       case 'convert':
-        $and = '';
-        if (!empty($vids)) {
-          $and = " AND td.vid IN(" . implode(', ', $vids) . ')';
-        }
+        $query = db_select('taxonomy_term_data', 'td');
+        $query->leftJoin('taxonomy_vocabulary', 'tv', 'td.vid = tv.vid');
+        $query->fields('td');
+        $query->fields('tv', array('machine_name'));
         if ($transform) {
-          $result = db_query("SELECT td.* FROM {taxonomy_term_data} td WHERE (replace(td.name, ' ', '-') = :name $and", array(
-            ':name' => $argument))->fetchObject();
+          $query->where("replace(td.name, ' ', '-') = :name", array(':name' => $argument));
         }
         else {
-          $result = db_query("SELECT td.* FROM {taxonomy_term_data} td WHERE td.name = :name $and", array(
-            ':name' => $argument))->fetchObject();
-        }
-        if (!$result) {
-          return FALSE;
+          $query->condition('td.name', $argument);
         }
+        $term = $query->execute()->fetchObject();
 
-        if ($type == 'convert') {
-          $this->argument->argument = $result->tid;
-          $this->argument->validated_title = check_plain($result->name);
+        if ($term && (empty($vocabularies) || !empty($vocabularies[$term->machine_name]))) {
+          if ($type == 'convert') {
+            $this->argument->argument = $term->tid;
+            $this->argument->validated_title = check_plain($term->name);
+          }
+          return TRUE;
         }
-
-        return TRUE;
+        return FALSE;
     }
   }
 }
