--- modules/taxonomy/taxonomy.module.orig 2008-04-28 23:59:30.000000000 +0200 +++ modules/taxonomy/taxonomy.module 2008-04-29 00:00:59.000000000 +0200 @@ -623,6 +623,7 @@ function taxonomy_node_get_terms($node, $terms[$node->vid][$key] = array(); while ($term = db_fetch_object($result)) { $terms[$node->vid][$key][$term->$key] = $term; + taxonomy_set_term($term->tid, $term); } } return $terms[$node->vid][$key]; @@ -1004,6 +1005,39 @@ function taxonomy_vocabulary_load($vid) } /** + * Set and return the term matching a term ID + * + * @param $tid + * A term's ID + * + * @param $term + * A term + * + * @param $reset + * Set this to true to refresh the term cache + * + * @return Object|Boolean + * A term object or boolean when no term was found. Results are statically cached. + */ +function taxonomy_set_term($tid, $term = null, $reset = null) { + static $terms = array(); + + if ($reset == true) { + $terms = true; + } + + if (!isset($terms[$tid]) && isset($term)) { + $terms[$tid] = $term; + } + + if (isset($terms[$tid])) { + return $terms[$tid]; + } + + return false; +} + +/** * Return the term object matching a term ID. * * @param $tid @@ -1012,14 +1046,12 @@ function taxonomy_vocabulary_load($vid) * @return Object * A term object. Results are statically cached. */ -function taxonomy_get_term($tid) { - static $terms = array(); - - if (!isset($terms[$tid])) { - $terms[$tid] = db_fetch_object(db_query('SELECT * FROM {term_data} WHERE tid = %d', $tid)); +function taxonomy_get_term($tid) { + if (!$term = taxonomy_set_term($tid)) { + $term = taxonomy_set_term($tid, db_fetch_object(db_query('SELECT * FROM {term_data} WHERE tid = %d', $tid))); } - - return $terms[$tid]; + + return $term; } function _taxonomy_term_select($title, $name, $value, $vocabulary_id, $description, $multiple, $blank, $exclude = array()) {