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 19:18:15 -0000
@@ -965,7 +965,24 @@ function taxonomy_get_children($tid, $vi
  *   Results are statically cached.
  */
 function taxonomy_get_tree($vid, $parent = 0, $depth = -1, $max_depth = NULL) {
-  static $children, $parents, $terms;
+  // Check for a cached version of this vocabulary's tree with the given params.
+  $id = $vid;
+  if ($parent != 0) {
+    $id .= ':'. $parent;
+  }
+  if ($depth != -1) {
+    $id .= ':'. $depth;
+  }
+  if (isset($max_depth)) {
+    $id .= ':'. $max_depth;
+  }
+  if ($cached = cache_get($id, 'cache')) {
+    return $cached->data;
+  }
+
+  $children = array();
+  $parents = array();
+  $terms = array();
 
   $depth++;
 
@@ -1000,6 +1017,8 @@ function taxonomy_get_tree($vid, $parent
     }
   }
 
+  cache_set($id, 'cache', $tree);
+
   return $tree ? $tree : array();
 }
 
