/**
* 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();
/**
* Save term associations for a given node.
*/
-function taxonomy_node_save($node, $terms) {
+function taxonomy_node_save(&$node, $terms) {
taxonomy_node_delete_revision($node);
}
}
}
+
+ // Flush the term "cache" for this node
+ $node->taxonomy = taxonomy_node_get_terms($node, 'tid', TRUE);
}
/**
/**
* 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);