? patches
? token_profile.inc
Index: token.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/token/token.module,v
retrieving revision 1.7.4.47
diff -u -p -r1.7.4.47 token.module
--- token.module	13 Dec 2010 21:52:28 -0000	1.7.4.47
+++ token.module	14 Dec 2010 17:29:59 -0000
@@ -310,22 +310,16 @@ function token_replace_multiple($text, $
  * should be run through token_prepare_tokens().
  */
 function token_get_values($type = 'global', $object = NULL, $flush = FALSE, $options = array()) {
-  static $tokens;
-  static $running;
+  static $tokens = array();
+  static $running = FALSE;
 
   // 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)) {
+  if ($flush) {
     $tokens = array();
   }
 
-  // Since objects in PHP5 are always passed by reference, we ensure we're
-  // working on a copy of the object.
-  if (is_object($object)) {
-    $object = drupal_clone($object);
-  }
-
   // 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...
@@ -343,18 +337,14 @@ function token_get_values($type = 'globa
   token_include();
 
   $id = _token_get_id($type, $object);
-  if ($id && 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;
+  if (!isset($tokens[$type][$id])) {
+    $tokens[$type][$id] = module_invoke_all('token_values', $type, $object, $options);
   }
 
   // Special-case global tokens, as we always want to be able to process
   // those substitutions.
   if (!isset($tokens['global']['default'])) {
-    $tokens['global']['default'] = module_invoke_all('token_values', 'global');
+    $tokens['global']['default'] = module_invoke_all('token_values', 'global', NULL, $options);
   }
 
   $all = array_merge($tokens['global']['default'], $tokens[$type][$id]);
@@ -442,14 +432,16 @@ function _token_get_id($type = 'global',
     return "default";
   }
   switch ($type) {
-    case 'node':
-      return isset($object->nid) ? $object->nid : 0;
     case 'comment':
       return isset($object->cid) ? $object->cid : 0;
-    case 'user':
-      return isset($object->uid) ? $object->uid : 0;
+    case 'node':
+      return isset($object->nid) ? $object->nid : 0;
     case 'taxonomy':
       return isset($object->tid) ? $object->tid : 0;
+    case 'vocabulary':
+      return isset($object->vid) ? $object->vid : 0;
+    case 'user':
+      return isset($object->uid) ? $object->uid : 0;
     default:
       return crc32(serialize($object));
   }
@@ -486,26 +478,25 @@ function token_get_date_token_info($desc
  * Build a list of common date tokens for use in hook_token_values().
  */
 function token_get_date_token_values($timestamp = NULL, $token_prefix = '', $langcode = NULL) {
-  static $formats;
+  static $formats, $timestamp;
 
   if (!isset($formats)) {
-    $formats = array(
-      'yyyy' => 'Y',
-      'yy' => 'y',
-      'month' => 'F',
-      'mon' => 'M',
-      'mm' => 'm',
-      'm' => 'n',
-      'ww' => 'W',
-      'date' => 'N', // PHP 5.1 only.
-      'day' => 'l',
-      'ddd' => 'D',
-      'dd' => 'd',
-      'd' => 'j',
-    );
-    if (!version_compare(PHP_VERSION, '5.1.0', '>=')) {
-      unset($formats['date']);
-    }
+    $formats = array();
+    $formats['small'] = variable_get('date_format_short', 'm/d/Y - H:i');
+    $formats['yyyy']  = 'Y';
+    $formats['yy']    = 'y';
+    $formats['month'] = 'F';
+    $formats['mon']   = 'M';
+    $formats['mm']    = 'm';
+    $formats['m']     = 'n';
+    $formats['ww']    = 'ww';
+    if (version_compare(PHP_VERSION, '5.1.0', '>=')) {
+      $formats['date'] = 'N';
+    }
+    $formats['day']   = 'l';
+    $formats['ddd']   = 'D';
+    $formats['dd']    = 'd';
+    $formats['d']     = 'j';
   }
 
   $time = time();
@@ -517,7 +508,6 @@ function token_get_date_token_values($ti
   foreach ($formats as $token => $format) {
     $tokens[$token_prefix . $token] = token_format_date($timestamp, 'custom', $format, NULL, $langcode);
   }
-  $tokens[$token_prefix . 'small'] = token_format_date($timestamp, 'small', '', NULL, $langcode);
   $tokens[$token_prefix . 'raw'] = $timestamp;
   $tokens[$token_prefix . 'since'] = format_interval($time - $timestamp, 2, $langcode);
 
@@ -530,17 +520,21 @@ function token_get_date_token_values($ti
  * @see format_date()
  */
 function token_format_date($timestamp, $type = 'medium', $format = '', $timezone = NULL, $langcode = NULL) {
-  if (!isset($timezone)) {
-    global $user;
-    if (variable_get('configurable_timezones', 1) && $user->uid && strlen($user->timezone)) {
-      $timezone = $user->timezone;
+  global $user;
+  static $timezones = array();
+
+  // Statically cache each user's timezone so it doesn't need to be re-fetched
+  // ever call.
+  if (!isset($timezones[$user->uid])) {
+    if (!empty($user->uid) && variable_get('configurable_timezones', 1) && strlen($user->timezone)) {
+      $timezones[$user->uid] = $user->timezone;
     }
     else {
-      $timezone = variable_get('date_default_timezone', 0);
+      $timezones[$user->uid] = variable_get('date_default_timezone', 0);
     }
   }
 
-  $timestamp += $timezone;
+  $timestamp += $timezones[$user->uid];
 
   switch ($type) {
     case 'small':
