Index: includes/bootstrap.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/bootstrap.inc,v
retrieving revision 1.243
diff -u -p -r1.243 bootstrap.inc
--- includes/bootstrap.inc	31 Oct 2008 02:18:22 -0000	1.243
+++ includes/bootstrap.inc	2 Nov 2008 01:33:22 -0000
@@ -496,7 +496,7 @@ function conf_init() {
  *   The filename of the requested item.
  */
 function drupal_get_filename($type, $name, $filename = NULL) {
-  static $files = array();
+  $files =& statics()->value(__FUNCTION__, 'files', array());
 
   if (!isset($files[$type])) {
     $files[$type] = array();
@@ -1169,7 +1169,8 @@ function drupal_maintenance_theme() {
  * run both during installation and normal operation.
  */
 function get_t() {
-  static $t;
+  $t =& statics()->value(__FUNCTION__, 't');
+
   if (is_null($t)) {
     $t = function_exists('install_main') ? 'st' : 't';
   }
@@ -1200,7 +1201,7 @@ function drupal_init_language() {
  * @param $reset Boolean to request a reset of the list.
  */
 function language_list($field = 'language', $reset = FALSE) {
-  static $languages = NULL;
+  $languages  =& statics()->value(__FUNCTION__, 'languages');
 
   // Reset language list
   if ($reset) {
@@ -1259,7 +1260,7 @@ function language_default($property = NU
  *   environments.
  */
 function ip_address($reset = FALSE) {
-  static $ip_address = NULL;
+  $ip_address  =& statics()->value(__FUNCTION__, 'ip_address');
 
   if (!isset($ip_address) || $reset) {
     $ip_address = $_SERVER['REMOTE_ADDR'];
@@ -1290,6 +1291,82 @@ function ip_address($reset = FALSE) {
 }
 
 /**
+ * Singleton class for the central static caching facility.
+ */
+class StaticsContainer {
+
+  /**
+   * Central static cache array.
+   *
+   * @var array
+   */
+  protected $cache = array();
+
+  /**
+   * Retrieves the statically cached specified value.
+   *
+   * This method must be called by reference.
+   *
+   * @param $context
+   *  A globally unique string, typically the name of the function
+   *  calling the method. Use, for example, __FUNCTION__ or for a
+   *  singleton object __CLASS__ . '::' . __METHOD__.
+   * @param $name
+   *   A key for the value being cached; unique for a given $context.
+   * @param $default
+   *   The default value for the specified key if it hasn't been created yet.
+   * @return
+   *   A reference to the requested static variable.
+   */
+  public function &value($context, $name, $default = NULL) {
+    // Store the default, if not yet set to a non-NULL value.
+    if (!isset($this->cache[$context][$name])) {
+      $this->cache[$context][$name] = $default;
+    }
+    return $this->cache[$context][$name];
+  }
+
+  /**
+   * Reset a statically cached value.
+   *
+   * If the value has no default specified yet, it will be set to NULL.
+   *
+   * @param $context
+   *  The globally unique string, typically the name of the function
+   *  calling the method. NULL to reset all values.
+   * @param $name
+   *   The name of the value to be reset, or NULL to reset all
+   *   values in the given context.
+   */
+  public function reset($context = NULL, $name = NULL) {
+    if (isset($name) && isset($context)) {
+      $this->cache[$context][$name] = NULL;
+    }
+    elseif (isset($context)) {
+      $this->cache[$context] = array();
+    }
+    else {
+      $this->cache = array();
+    }
+  }
+}
+
+/**
+ * Singleton factory wrapper for the Statics class.
+ *
+ * @return
+ *   The Statics singleton.
+ */
+function statics() {
+  static $instance;
+  
+  if (empty($instance)) {
+    $instance = new StaticsContainer;
+  }
+  return $instance;
+}
+
+/**
  * @ingroup schemaapi
  * @{
  */
