--- modules/forum/forum.module.orig	Wed Jun  3 12:27:48 2009
+++ modules/forum/forum.module	Tue Jul 14 12:00:59 2009
@@ -250,9 +250,29 @@ function forum_nodeapi(&$node, $op, $tea
         foreach ($tree as $term) {
           $forum_terms[] = $term->tid;
         }
-        foreach ($node->taxonomy as $term_id) {
-          if (in_array($term_id, $forum_terms)) {
-            $node->tid = $term_id;
+        // $node->taxonomy can be one of 3 types:
+        // Array of term objects keyed by tid, term object, or a single tid
+        // This code, based on Drupal 7's taxonomy save function, handles all 3
+        // See issue at: http://drupal.org/user/28680
+        if (is_array($node->taxonomy)) {
+          // Array of term objects keyed by tid
+          foreach ($node->taxonomy as $term_id => $term) {
+            if ($term_id && in_array($term_id, $forum_terms)) {
+              $node->tid = $term_id;
+            }
+          }
+        }
+        elseif (is_object($node->taxonomy)) {
+          // Single term object
+            $term = $node->taxonomy;
+            if ($term->tid && in_array($term->tid, $forum_terms)) {
+              $node->tid = $term->tid;
+            }
+        }
+        elseif ($node->taxonomy) {
+          // Single numeric tid
+          if (in_array($node->taxonomy, $forum_terms)) {
+            $node->tid = $node->taxonomy;
           }
         }
         $old_tid = db_result(db_query_range("SELECT t.tid FROM {term_node} t INNER JOIN {node} n ON t.vid = n.vid WHERE n.nid = %d ORDER BY t.vid DESC", $node->nid, 0, 1));
