diff --git modules/taxonomy/taxonomy.module modules/taxonomy/taxonomy.module index 70f4c3b..ed3223d 100644 --- modules/taxonomy/taxonomy.module +++ modules/taxonomy/taxonomy.module @@ -610,9 +610,13 @@ function taxonomy_node_get_terms_by_vocabulary($node, $vid, $key = 'tid') { /** * Find all terms associated with the given node, ordered by vocabulary and term weight. */ -function taxonomy_node_get_terms($node, $key = 'tid') { +function taxonomy_node_get_terms($node, $key = 'tid', $reset = FALSE) { static $terms; + if ($reset) { + unset($terms[$node->vid]); + } + if (!isset($terms[$node->vid][$key])) { $result = db_query(db_rewrite_sql('SELECT t.* FROM {term_node} r INNER JOIN {term_data} t ON r.tid = t.tid INNER JOIN {vocabulary} v ON t.vid = v.vid WHERE r.vid = %d ORDER BY v.weight, t.weight, t.name', 't', 'tid'), $node->vid); $terms[$node->vid][$key] = array(); @@ -702,6 +706,9 @@ function taxonomy_node_save($node, $terms) { } } } + + // Flush the term "cache" for this node + taxonomy_node_get_terms($node, 'tid', TRUE); } /** @@ -1180,7 +1187,7 @@ function taxonomy_render_nodes($result) { /** * Implementation of hook_nodeapi(). */ -function taxonomy_nodeapi($node, $op, $arg = 0) { +function taxonomy_nodeapi(&$node, $op, $arg = 0) { switch ($op) { case 'load': $output['taxonomy'] = taxonomy_node_get_terms($node); @@ -1189,12 +1196,14 @@ function taxonomy_nodeapi($node, $op, $arg = 0) { case 'insert': if (!empty($node->taxonomy)) { taxonomy_node_save($node, $node->taxonomy); + $node->taxonomy = taxonomy_node_get_terms($node); } break; case 'update': if (!empty($node->taxonomy)) { taxonomy_node_save($node, $node->taxonomy); + $node->taxonomy = taxonomy_node_get_terms($node); } break;