Index: modules/taxonomy/taxonomy.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/taxonomy/taxonomy.module,v
retrieving revision 1.330
diff -u -p -r1.330 taxonomy.module
--- modules/taxonomy/taxonomy.module   11 Jan 2007 03:29:15 -0000   1.330
+++ modules/taxonomy/taxonomy.module   25 Jan 2007 18:49:31 -0000
@@ -525,6 +525,9 @@ function taxonomy_save_term(&$form_value
     module_invoke_all('taxonomy', $hook, 'term', $form_values);
   }
 
+  // Clear the taxonomy tree static cache.
+  taxonomy_get_tree(NULL, NULL, NULL, NULL, TRUE);
+
   cache_clear_all();
 
   return $status;
@@ -568,6 +571,9 @@ function taxonomy_del_term($tid) {
     $tids = $orphans;
   }
 
+  // Clear the taxonomy tree static cache after deleting any terms.
+  taxonomy_get_tree(NULL, NULL, NULL, NULL, TRUE);
+
   cache_clear_all();
 
   return SAVED_DELETED;
@@ -959,13 +965,26 @@ function taxonomy_get_children($tid, $vi
  * @param $max_depth
  *   The number of levels of the tree to return. Leave NULL to return all levels.
  *
+ * @param $reset
+ *   Whether to reset the internal taxonomy tree static cache.
+ *
  * @return
  *   An array of all term objects in the tree. Each term object is extended
  *   to have "depth" and "parents" attributes in addition to its normal ones.
- *   Results are statically cached.
+ *   Results are statically cached. If $reset is set to TRUE, this function
+ *   will return NULL.
  */
-function taxonomy_get_tree($vid, $parent = 0, $depth = -1, $max_depth = NULL) {
-  static $children, $parents, $terms;
+function taxonomy_get_tree($vid, $parent = 0, $depth = -1, $max_depth = NULL, $reset = FALSE) {
+  static $children = array(), $parents = array(), $terms = array();
+
+  // If we're resetting the static cache, do not process the tree for
+  // performance.
+  if ($reset) {
+    $children = array();
+    $parents = array();
+    $terms = array();
+    return;
+  }
 
   $depth++;
 
