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 02:03:47 -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('drupal_get_filename.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('get_t.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('language_list.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('ip_address.ip_address');
 
   if (!isset($ip_address) || $reset) {
     $ip_address = $_SERVER['REMOTE_ADDR'];
@@ -1290,6 +1291,72 @@ 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 $name
+   *   A globally unique key for the value being cached. For example,
+   *   prefix with the function name.
+   * @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($name, $default = NULL) {
+    if (!isset($this->cache[$name])) {
+      $this->cache[$name] = $default;
+    }
+    return $this->cache[$name];
+  }
+
+  /**
+   * Reset a statically cached value.
+   *
+   * If the value has no default specified yet, it will be set to NULL.
+   *
+   * @param $name
+   *   The name of the value to be reset, or NULL to reset all
+   *   values.
+   */
+  public function reset($name = NULL) {
+    if (isset($name)) {
+      $this->cache[$name] = NULL;
+    }
+    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
  * @{
  */
