Index: token.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/token/token.module,v
retrieving revision 1.5.2.10
diff -u -r1.5.2.10 token.module
--- token.module	16 Nov 2007 22:29:40 -0000	1.5.2.10
+++ token.module	22 Nov 2007 22:01:05 -0000
@@ -206,20 +206,21 @@
  *   values for the passed-in type and object.
  */
 function token_get_values($type = 'global', $object = NULL, $flush = FALSE, $options = array()) {
-  static $tokens;
   static $running;
 
   // Flush the static token cache. Useful for processes that need to slog through
   // huge numbers of tokens in a single execution cycle. Flushing it will keep
   // them from burning through memory.
-  if ($flush || !isset($tokens)) {
-    $tokens = array();
+  $tokens = array();
+
+  if (!isset($running)) {
+    $running = 0;
   }
 
   // Simple recursion check. This is to avoid content_view()'s potential
   // for endless looping when a filter uses tokens, which load the content
   // view, which calls the filter, which uses tokens, which...
-  if ($running) {
+  if ($running > 2) {
     // We'll allow things to get two levels deep, but bail out after that
     // without performing any substitutions.
     $result = new stdClass();
@@ -227,19 +228,13 @@
     $result->values = array();
     return $result;
   }
-  
-  $running = TRUE;
+  $running = $running + 1;
 
   token_include();
 
   $id = _token_get_id($type, $object);
-  if (isset($tokens[$type][$id])) {
-    $tmp_tokens = $tokens[$type][$id];
-  }
-  else {
-    $tmp_tokens = module_invoke_all('token_values', $type, $object, $options);
-    $tokens[$type][$id] = $tmp_tokens;
-  }
+  $tmp_tokens = module_invoke_all('token_values', $type, $object, $options);
+  $tokens[$type][$id] = $tmp_tokens;
 
   // Special-case global tokens, as we always want to be able to process
   // those substitutions.
@@ -253,8 +248,7 @@
   $result->tokens = array_keys($all);
   $result->values = array_values($all);
 
-  $running = FALSE;
-
+  drupal_set_message('<pre>'.print_r($result,TRUE).'</pre>');
   return $result;
 }
 
