Index: modules/forum/forum.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/forum/forum.module,v
retrieving revision 1.534
diff -u -9 -p -r1.534 forum.module
--- modules/forum/forum.module	21 Nov 2009 20:33:56 -0000	1.534
+++ modules/forum/forum.module	26 Nov 2009 18:50:34 -0000
@@ -182,37 +182,37 @@ function forum_node_view($node, $build_m
 }
 
 /**
  * Implement hook_node_prepare().
  */
 function forum_node_prepare($node) {
   if (_forum_node_check_node_type($node)) {
     if (empty($node->nid)) {
       // New topic
-      $node->taxonomy_forums[0]['value'] =  arg(3);
+      $node->taxonomy_forums[0]['tid'] =  arg(3);
     }
   }
 }
 
 /**
  * Implement hook_node_validate().
  *
  * Check in particular that only a "leaf" term in the associated taxonomy.
  */
 function forum_node_validate($node, $form) {
   if (_forum_node_check_node_type($node)) {
     $langcode = $form['taxonomy_forums']['#language'];
     // vocabulary is selected, not a "container" term.
     if (!empty($node->taxonomy_forums[$langcode])) {
       // Extract the node's proper topic ID.
       $containers = variable_get('forum_containers', array());
-      foreach ($node->taxonomy_forums[$langcode] as $tid) {
-        $term = taxonomy_term_load($tid['value']);
+      foreach ($node->taxonomy_forums[$langcode] as $item) {
+        $term = taxonomy_term_load($item['tid']);
         $used = db_query_range('SELECT 1 FROM {taxonomy_term_data} WHERE tid = :tid AND vid = :vid',0 , 1, array(
           ':tid' => $term->tid,
           ':vid' => $term->vid,
         ))->fetchField();
         if ($used && in_array($term->tid, $containers)) {
           form_set_error('taxonomy_forums', t('The item %forum is only a forum container. Select one of the forums below it.', array('%forum' => $term->name)));
         }
       }
     }
@@ -224,23 +224,23 @@ function forum_node_validate($node, $for
  *
  * Assign forum taxonomy when adding a topic from within a forum.
  */
 function forum_node_presave($node) {
   if (_forum_node_check_node_type($node)) {
     // Make sure all fields are set properly:
     $node->icon = !empty($node->icon) ? $node->icon : '';
     $langcode = array_shift(array_keys($node->taxonomy_forums));
     if (!empty($node->taxonomy_forums[$langcode])) {
-      $node->forum_tid = $node->taxonomy_forums[$langcode][0]['value'];
+      $node->forum_tid = $node->taxonomy_forums[$langcode][0]['tid'];
       $old_tid = db_query_range("SELECT f.tid FROM {forum} f INNER JOIN {node} n ON f.vid = n.vid WHERE n.nid = :nid ORDER BY f.vid DESC", 0, 1, array(':nid' => $node->nid))->fetchField();
       if ($old_tid && isset($node->forum_tid) && ($node->forum_tid != $old_tid) && !empty($node->shadow)) {
         // A shadow copy needs to be created. Retain new term and add old term.
-        $node->taxonomy_forums[$langcode][] = array('value' => $old_tid);
+        $node->taxonomy_forums[$langcode][] = array('tid' => $old_tid);
       }
     }
   }
 }
 
 /**
  * Implement hook_node_update().
  */
 function forum_node_update($node) {
@@ -420,23 +420,23 @@ function forum_comment_delete($comment) 
 }
 
 /**
  * Implement hook_field_storage_pre_insert().
  */
 function forum_field_storage_pre_insert($obj_type, $object, &$skip_fields) {
   if ($obj_type == 'node' && $object->status && _forum_node_check_node_type($object)) {
     $query = db_insert('forum_index')->fields(array('nid', 'title', 'tid', 'sticky', 'created', 'comment_count', 'last_comment_timestamp'));
     foreach ($object->taxonomy_forums as $language) {
-      foreach ($language as $delta) {
+      foreach ($language as $item) {
         $query->values(array(
           'nid' => $object->nid,
           'title' => $object->title[FIELD_LANGUAGE_NONE][0]['value'],
-          'tid' => $delta['value'],
+          'tid' => $item['tid'],
           'sticky' => $object->sticky,
           'created' => $object->created,
           'comment_count' => 0,
           'last_comment_timestamp' => $object->created,
         ));
       }
     }
     $query->execute();
   }
@@ -454,23 +454,23 @@ function forum_field_storage_pre_update(
     // sure we only wipe values once.
     if (!isset($first_call[$object->nid])) {
       $first_call[$object->nid] = FALSE;
       db_delete('forum_index')->condition('nid', $object->nid)->execute();
     }
     // Only save data to the table if the node is published.
     if ($object->status) {
       $query = db_insert('forum_index')->fields(array('nid', 'title', 'tid', 'sticky', 'created', 'comment_count', 'last_comment_timestamp'));
       foreach ($object->taxonomy_forums as $language) {
-        foreach ($language as $delta) {
+        foreach ($language as $item) {
           $query->values(array(
             'nid' => $object->nid,
             'title' => $object->title[FIELD_LANGUAGE_NONE][0]['value'],
-            'tid' => $delta['value'],
+            'tid' => $item['tid'],
             'sticky' => $object->sticky,
             'created' => $object->created,
             'comment_count' => 0,
             'last_comment_timestamp' => $object->created,
           ));
         }
       }
       $query->execute();
       // The logic for determining last_comment_count is fairly complex, so
Index: modules/taxonomy/taxonomy.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/taxonomy/taxonomy.module,v
retrieving revision 1.540
diff -u -9 -p -r1.540 taxonomy.module
--- modules/taxonomy/taxonomy.module	20 Nov 2009 05:14:13 -0000	1.540
+++ modules/taxonomy/taxonomy.module	26 Nov 2009 18:50:35 -0000
@@ -993,26 +993,26 @@ function taxonomy_field_widget_info_alte
   $info['options_buttons']['field types'][] = 'taxonomy_term';
 }
 
 /**
  * Implement hook_field_schema().
  */
 function taxonomy_field_schema($field) {
   return array(
     'columns' => array(
-      'value' => array(
+      'tid' => array(
         'type' => 'int',
         'unsigned' => TRUE,
         'not null' => FALSE,
       ),
     ),
     'indexes' => array(
-      'value' => array('value'),
+      'tid' => array('tid'),
     ),
   );
 }
 
 /**
  * Implement hook_field_validate().
  *
  * Possible error codes:
  * - 'taxonomy_term_illegal_value': The value is not part of the list of allowed values.
@@ -1027,34 +1027,34 @@ function taxonomy_field_validate($obj_ty
     if (count($items) > $field['cardinality']) {
       $errors[$field['field_name']][$langcode][0][] = array(
         'error' => 'taxonomy_term_illegal_value',
         'message' => t('%name: this field cannot hold more that @count values.', array('%name' => t($instance['label']), '@count' => $field['cardinality'])),
       );
     }
   }
 
   foreach ($items as $delta => $item) {
-    if (!empty($item['value'])) {
-      if (!isset($allowed_values[$item['value']])) {
+    if (!empty($item['tid'])) {
+      if (!isset($allowed_values[$item['tid']])) {
         $errors[$field['field_name']][$langcode][$delta][] = array(
           'error' => 'taxonomy_term_illegal_value',
           'message' => t('%name: illegal value.', array('%name' => t($instance['label']))),
         );
       }
     }
   }
 }
 
 /**
  * Implement hook_field_is_empty().
  */
 function taxonomy_field_is_empty($item, $field) {
-  if (!is_array($item) || (empty($item['value']) && (string) $item['value'] !== '0')) {
+  if (!is_array($item) || (empty($item['tid']) && (string) $item['tid'] !== '0')) {
     return TRUE;
   }
   return FALSE;
 }
 
 /**
  * Implement hook_field_formatter_info().
  */
 function taxonomy_field_formatter_info() {
@@ -1121,31 +1121,31 @@ function taxonomy_allowed_values($field)
  * unsets values for invalid terms that do not exist.
  */
 function taxonomy_field_formatter_prepare_view($obj_type, $objects, $field, $instances, $langcode, &$items, $age) {
   $tids = array();
 
   // Collect every possible term attached to any of the fieldable entities.
   foreach ($objects as $id => $object) {
     foreach ($items[$id] as $delta => $item) {
       // Force the array key to prevent duplicates.
-      $tids[$item['value']] = $item['value'];
+      $tids[$item['tid']] = $item['tid'];
     }
   }
   if ($tids) {
     $terms = taxonomy_term_load_multiple($tids);
 
     // Iterate through the fieldable entities again to attach the loaded term data.
     foreach ($objects as $id => $object) {
       foreach ($items[$id] as $delta => $item) {
         // Check whether the taxonomy term field instance value could be loaded.
-        if (isset($terms[$item['value']])) {
+        if (isset($terms[$item['tid']])) {
           // Replace the instance value with the term data.
-          $items[$id][$delta]['taxonomy_term'] = $terms[$item['value']];
+          $items[$id][$delta]['taxonomy_term'] = $terms[$item['tid']];
         }
         // Otherwise, unset the instance value, since the term does not exist.
         else {
           unset($items[$id][$delta]);
         }
       }
     }
   }
 }
@@ -1169,19 +1169,19 @@ function _taxonomy_clean_field_cache($te
   foreach ($fields as $field_name => $field) {
 
     // Assemble an array of vocabulary IDs that are used in this field.
     foreach ($field['settings']['allowed_values'] as $tree) {
       $vids[$tree['vid']] = $tree['vid'];
     }
 
     // Check this term's vocabulary against those used for the field's options.
     if (in_array($term->vid, $vids)) {
-      $conditions = array(array('value', $term->tid));
+      $conditions = array(array('tid', $term->tid));
       if ($obj_types) {
         $conditions[] = array('type', $obj_types, 'NOT IN');
       }
       $results = field_attach_query($field['id'], $conditions, array('limit' => FIELD_QUERY_NO_LIMIT));
       foreach ($results as $obj_type => $objects) {
         foreach (array_keys($objects) as $id) {
           $cids[] = "field:$obj_type:$id";
         }
       }
@@ -1204,19 +1204,19 @@ function taxonomy_term_title($term) {
   return check_plain($term->name);
 }
 
 /**
  * Implement hook_field_widget().
  */
 function taxonomy_field_widget(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
   $tags = array();
   foreach ($items as $item) {
-    $tags[$item['value']] = isset($item['taxonomy_term']) ? $item['taxonomy_term'] : taxonomy_term_load($item['value']);
+    $tags[$item['tid']] = isset($item['taxonomy_term']) ? $item['taxonomy_term'] : taxonomy_term_load($item['tid']);
   }
 
   $element += array(
     '#type' => 'textfield',
     '#default_value' => taxonomy_implode_tags($tags),
     '#autocomplete_path' => $instance['widget']['settings']['autocomplete_path'] . '/' . $field['field_name'],
     '#size' => $instance['widget']['settings']['size'],
     '#element_validate' => array('taxonomy_autocomplete_validate'),
   );
@@ -1252,37 +1252,32 @@ function taxonomy_autocomplete_validate(
         $term = (object) array(
           'vid' => $vids[0],
           'name' => $typed_term,
           'vocabulary_machine_name' => $vocabulary->machine_name,
         );
         taxonomy_term_save($term);
       }
       $values[] = $term->tid;
     }
-    $value = options_array_transpose(array('value' => $values));
+    $value = options_array_transpose(array('tid' => $values));
   }
   else {
     $value = array();
   }
 
   form_set_value($element, $value, $form_state);
 }
 
 /**
  * Implement hook_field_widget_error().
  */
 function taxonomy_field_widget_error($element, $error) {
-  if ($element['#type'] == 'textfield') {
-    form_error($element, $error['message']);
-  }
-  else {
-    form_error($element['value'], $error['message']);
-  }
+  form_error($element, $error['message']);
 }
 
 /**
  * Implement hook_field_settings_form().
  */
 function taxonomy_field_settings_form($field, $instance, $has_data) {
   // Get proper values for 'allowed_values_function', which is a core setting.
   $vocabularies = taxonomy_get_vocabularies();
   $options = array();
@@ -1375,19 +1370,19 @@ function taxonomy_rdf_mapping() {
  */
 function taxonomy_field_insert($obj_type, $object, $field, $instance, $langcode, &$items) {
   // We maintain a denormalized table of term/node relationships, containing
   // only data for current, published nodes.
   if (variable_get('taxonomy_maintain_index_table', TRUE) && $field['storage']['type'] == 'field_sql_storage' && $obj_type == 'node' && $object->status) {
     $query = db_insert('taxonomy_index')->fields(array('nid', 'tid', 'sticky', 'created', ));
     foreach ($items as $item) {
       $query->values(array(
         'nid' => $object->nid,
-        'tid' => $item['value'],
+        'tid' => $item['tid'],
         'sticky' => $object->sticky,
         'created' => $object->created,
       ));
     }
     $query->execute();
   }
 }
 
 /**
@@ -1404,19 +1399,19 @@ function taxonomy_field_update($obj_type
       $first_call[$object->nid] = FALSE;
       db_delete('taxonomy_index')->condition('nid', $object->nid)->execute();
     }
     // Only save data to the table if the node is published.
     if ($object->status) {
       $query = db_insert('taxonomy_index')->fields(array('nid', 'tid', 'sticky', 'created'));
       foreach ($items as $item) {
         $query->values(array(
           'nid' => $object->nid,
-          'tid' => $item['value'],
+          'tid' => $item['tid'],
           'sticky' => $object->sticky,
           'created' => $object->created,
         ));
       }
       $query->execute();
     }
   }
 }
 
Index: modules/taxonomy/taxonomy.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/taxonomy/taxonomy.test,v
retrieving revision 1.61
diff -u -9 -p -r1.61 taxonomy.test
--- modules/taxonomy/taxonomy.test	20 Nov 2009 23:29:28 -0000	1.61
+++ modules/taxonomy/taxonomy.test	26 Nov 2009 18:50:35 -0000
@@ -748,35 +748,36 @@ class TaxonomyTermFieldTestCase extends 
         ),
       ),
     );
     field_create_instance($this->instance);
 
     // Test valid and invalid values with field_attach_validate().
     $langcode = FIELD_LANGUAGE_NONE;
     $entity = field_test_create_stub_entity();
     $term = $this->createTerm($this->vocabulary);
-    $entity->{$this->field_name}[$langcode][0]['value'] = $term->tid;
-    field_attach_validate('test_entity', $entity);
+    $entity->{$this->field_name}[$langcode][0]['tid'] = $term->tid;
     try {
-      $this->assertTrue($entity->{$this->field_name}[$langcode][0]['value'] == $term->tid, t('Correct term does not cause validation error'));
+      field_attach_validate('test_entity', $entity);
+      $this->pass(t('Correct term does not cause validation error'));
     }
     catch (FieldValidationException $e) {
-      $this->assertTrue($entity->{$this->field_name}[$langcode][0]['value'] != $term->tid, t('Term from wrong vocabulary does not cause validation error'));
+      $this->fail(t('Correct term does not cause validation error'));
     }
 
     $entity = field_test_create_stub_entity();
     $bad_term = $this->createTerm($this->createVocabulary());
-    $entity->{$this->field_name}[$langcode][0]['value'] = $bad_term->tid;
+    $entity->{$this->field_name}[$langcode][0]['tid'] = $bad_term->tid;
     try {
       field_attach_validate('test_entity', $entity);
+      $this->fail(t('Wrong term causes validation error'));
     }
     catch (FieldValidationException $e) {
-      $this->assertTrue($this->field['settings']['allowed_values'][0]['vid'] != $bad_term->vid, t('Wrong term causes validation error'));
+      $this->pass(t('Wrong term causes validation error'));
     }
   }
 
   /**
    * Test widgets.
    */
   function testTaxonomyTermFieldWidgets() {
     // Setup a field and instance.
     $entity_type = 'test_entity';
