? modules/system/system.path_lazy.inc
? modules/system/system.path_precache.inc
? includes/handlers.inc
Index: install.php
===================================================================
RCS file: /cvs/drupal/drupal/install.php,v
retrieving revision 1.160
diff -u -p -r1.160 install.php
--- install.php	17 Mar 2009 15:26:29 -0000	1.160
+++ install.php	22 Mar 2009 19:40:25 -0000
@@ -185,7 +185,8 @@ function install_verify_settings() {
     include_once DRUPAL_ROOT . '/includes/form.inc';
 
     $database = $databases['default']['default'];
-    $settings_file = './' . conf_path(FALSE, TRUE) . '/settings.php';
+    drupal_static_reset('conf_path');
+    $settings_file = './' . conf_path(FALSE) . '/settings.php';
 
     $form_state = array();
     _install_settings_form_validate($database, $settings_file, $form_state);
@@ -202,7 +203,8 @@ function install_verify_settings() {
 function install_change_settings($profile = 'default', $install_locale = '') {
   global $databases, $db_prefix;
 
-  $conf_path = './' . conf_path(FALSE, TRUE);
+  drupal_static_reset('conf_path');
+  $conf_path = './' . conf_path(FALSE);
   $settings_file = $conf_path . '/settings.php';
   $database = isset($databases['default']['default']) ? $databases['default']['default'] : array();
 
Index: modules/simpletest/tests/bootstrap.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/simpletest/tests/bootstrap.test,v
retrieving revision 1.12
diff -u -p -r1.12 bootstrap.test
--- modules/simpletest/tests/bootstrap.test	31 Jan 2009 16:50:57 -0000	1.12
+++ modules/simpletest/tests/bootstrap.test	22 Mar 2009 19:40:25 -0000
@@ -20,6 +20,8 @@ class BootstrapIPAddressTestCase extends
     $this->cluster_ip = '127.0.0.4';
     $this->untrusted_ip = '0.0.0.0';
 
+    drupal_static_reset('ip_address');
+
     $_SERVER['REMOTE_ADDR'] = $this->remote_ip;
     unset($_SERVER['HTTP_X_FORWARDED_FOR']);
     unset($_SERVER['HTTP_X_CLUSTER_CLIENT_IP']);
@@ -29,6 +31,7 @@ class BootstrapIPAddressTestCase extends
 
   function tearDown() {
     $_SERVER = $this->oldserver;
+    drupal_static_reset('ip_address');
     parent::tearDown();
   }
 
@@ -38,37 +41,40 @@ class BootstrapIPAddressTestCase extends
   function testIPAddressHost() {
     // Test the normal IP address.
     $this->assertTrue(
-      ip_address(true) == $this->remote_ip,
+      ip_address() == $this->remote_ip,
       t('Got remote IP address')
     );
 
     // Proxy forwarding on but no proxy addresses defined.
     variable_set('reverse_proxy', 1);
     $this->assertTrue(
-      ip_address(true) == $this->remote_ip,
+      ip_address() == $this->remote_ip,
       t('Proxy forwarding without trusted proxies got remote IP address')
     );
 
     // Proxy forwarding on and proxy address not trusted.
     variable_set('reverse_proxy_addresses', array($this->proxy_ip));
+    drupal_static_reset('ip_address');
     $_SERVER['REMOTE_ADDR'] = $this->untrusted_ip;
     $this->assertTrue(
-      ip_address(true) == $this->untrusted_ip,
+      ip_address() == $this->untrusted_ip,
       t('Proxy forwarding with untrusted proxy got remote IP address')
     );
 
     // Proxy forwarding on and proxy address trusted.
     $_SERVER['REMOTE_ADDR'] = $this->proxy_ip;
     $_SERVER['HTTP_X_FORWARDED_FOR'] = $this->forwarded_ip;
+    drupal_static_reset('ip_address');
     $this->assertTrue(
-      ip_address(true) == $this->forwarded_ip,
+      ip_address() == $this->forwarded_ip,
       t('Proxy forwarding with trusted proxy got forwarded IP address')
     );
 
     // Cluster environment.
     $_SERVER['HTTP_X_CLUSTER_CLIENT_IP'] = $this->cluster_ip;
+    drupal_static_reset('ip_address');
     $this->assertTrue(
-      ip_address(TRUE) == $this->cluster_ip,
+      ip_address() == $this->cluster_ip,
       t('Cluster environment got cluster client IP')
     );
     $this->assertFalse(drupal_valid_http_host('security/.drupal.org:80'), t('HTTP_HOST with / is invalid'));
Index: modules/translation/translation.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/translation/translation.test,v
retrieving revision 1.8
diff -u -p -r1.8 translation.test
--- modules/translation/translation.test	17 Mar 2009 04:22:50 -0000	1.8
+++ modules/translation/translation.test	22 Mar 2009 19:40:25 -0000
@@ -100,7 +100,9 @@ class TranslationTestCase extends Drupal
       $edit['langcode'] = $language_code;
       $this->drupalPost('admin/settings/language/add', $edit, t('Add language'));
 
-      $languages = language_list('language', TRUE); // Make sure we're not using a stale list.
+      // Make sure we're not using a stale list.
+      drupal_static_reset('language_list');
+      $languages = language_list('language');
       $this->assertTrue(array_key_exists($language_code, $languages), t('Language was installed successfully.'));
 
       if (array_key_exists($language_code, $languages)) {
Index: includes/bootstrap.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/bootstrap.inc,v
retrieving revision 1.272
diff -u -p -r1.272 bootstrap.inc
--- includes/bootstrap.inc	18 Mar 2009 09:21:21 -0000	1.272
+++ includes/bootstrap.inc	22 Mar 2009 19:40:25 -0000
@@ -360,7 +360,7 @@ function timer_stop($name) {
  *   The path of the matching directory.
  */
 function conf_path($require_settings = TRUE, $reset = FALSE) {
-  static $conf = '';
+  $conf = &drupal_static(__FUNCTION__, '');
 
   if ($conf && !$reset) {
     return $conf;
@@ -558,7 +558,7 @@ function conf_init() {
  *   The filename of the requested item.
  */
 function drupal_get_filename($type, $name, $filename = NULL) {
-  static $files = array();
+  $files = &drupal_static(__FUNCTION__, array());
 
   if (!isset($files[$type])) {
     $files[$type] = array();
@@ -727,7 +727,7 @@ function page_get_cache($retrieve) {
  *   TRUE if the item is loaded or has already been loaded.
  */
 function drupal_load($type, $name) {
-  static $files = array();
+  $files = &drupal_static(__FUNCTION__, array());
 
   if (isset($files[$type][$name])) {
     return TRUE;
@@ -1093,7 +1093,19 @@ function drupal_anonymous_user($session 
  *     DRUPAL_BOOTSTRAP_FULL: Drupal is fully loaded, validate and fix input data.
  */
 function drupal_bootstrap($phase = NULL) {
-  static $phases = array(DRUPAL_BOOTSTRAP_CONFIGURATION, DRUPAL_BOOTSTRAP_EARLY_PAGE_CACHE, DRUPAL_BOOTSTRAP_DATABASE, DRUPAL_BOOTSTRAP_ACCESS, DRUPAL_BOOTSTRAP_SESSION, DRUPAL_BOOTSTRAP_VARIABLES, DRUPAL_BOOTSTRAP_LATE_PAGE_CACHE, DRUPAL_BOOTSTRAP_LANGUAGE, DRUPAL_BOOTSTRAP_PATH, DRUPAL_BOOTSTRAP_FULL), $completed_phase = -1;
+  $phases = &drupal_static(__FUNCTION__ . '_phases', array(
+    DRUPAL_BOOTSTRAP_CONFIGURATION,
+    DRUPAL_BOOTSTRAP_EARLY_PAGE_CACHE,
+    DRUPAL_BOOTSTRAP_DATABASE,
+    DRUPAL_BOOTSTRAP_ACCESS,
+    DRUPAL_BOOTSTRAP_SESSION,
+    DRUPAL_BOOTSTRAP_VARIABLES,
+    DRUPAL_BOOTSTRAP_LATE_PAGE_CACHE,
+    DRUPAL_BOOTSTRAP_LANGUAGE,
+    DRUPAL_BOOTSTRAP_PATH,
+    DRUPAL_BOOTSTRAP_FULL,
+  ));
+  $completed_phase = &drupal_static(__FUNCTION__ . '_completed_phase', -1);
 
   if (isset($phase)) {
     while ($phases && $phase > $completed_phase) {
@@ -1251,7 +1263,9 @@ function drupal_maintenance_theme() {
  */
 function get_t() {
   static $t;
-  if (is_null($t)) {
+  // This is not converted to drupal_static because there is no point in
+  // resetting this as it can not change in the course of a request.
+  if (!isset($t)) {
     $t = function_exists('install_main') ? 'st' : 't';
   }
   return $t;
@@ -1278,16 +1292,9 @@ function drupal_init_language() {
  * Get a list of languages set up indexed by the specified key
  *
  * @param $field The field to index the list with.
- * @param $reset Boolean to request a reset of the list.
  */
-function language_list($field = 'language', $reset = FALSE) {
-  static $languages = NULL;
-
-  // Reset language list
-  if ($reset) {
-    $languages = NULL;
-  }
-
+function language_list($field = 'language') {
+  $languages = &drupal_static(__FUNCTION__);
   // Init language list
   if (!isset($languages)) {
     if (variable_get('language_count', 1) > 1 || module_exists('locale')) {
@@ -1333,16 +1340,14 @@ function language_default($property = NU
  * the proxy server, and not the client's. If Drupal is run in a cluster
  * we use the X-Cluster-Client-Ip header instead.
  *
- * @param $reset
- *   Reset the current IP address saved in static.
  * @return
  *   IP address of client machine, adjusted for reverse proxy and/or cluster
  *   environments.
  */
-function ip_address($reset = FALSE) {
-  static $ip_address = NULL;
+function ip_address() {
+  $ip_address = &drupal_static(__FUNCTION__);
 
-  if (!isset($ip_address) || $reset) {
+  if (!isset($ip_address)) {
     $ip_address = $_SERVER['REMOTE_ADDR'];
 
     if (variable_get('reverse_proxy', 0)) {
@@ -1616,3 +1621,53 @@ function registry_rebuild() {
 /**
  * @} End of "ingroup registry".
  */
+
+/**
+ * Central static variable storage.
+ *
+ * @param $name
+ *   Globally unique name for the variable. For a function with only one static,
+ *   variable, the function name (e.g. via the PHP magic __FUNCTION__ constant)
+ *   is recommended. For a function with multiple static variables add a 
+ *   distinguishing suffix to the function name for each one.
+ * @param $default_value
+ *   Optional default value.
+ * @param $reset
+ *   TRUE to reset a specific named variable, or all variables if $name is NULL.
+ *   Resetting every variable should only be used, for example, for running
+ *   unit tests with a clean environment. Should be used only though via
+ *   function drupal_static_reset().
+ *
+ * @return
+ *   Returns a variable by reference if $reset is FALSE.
+ */
+function &drupal_static($name, $default_value = NULL, $reset = FALSE) {
+  static $data = array();
+
+  // Reset a single value, or all values.
+  if ($reset) {
+    if (isset($name)) {
+      unset($data[$name]);
+    }
+    else {
+      $data = array();
+    }
+    return;
+  }
+
+  if (!isset($data[$name])) {
+    $data[$name] = $default_value;
+  }
+
+  return $data[$name];
+}
+
+/**
+ * Reset one or all centrally stored static variable(s).
+ *
+ * @param $name
+ *   Name of the static variable to reset. Omit to reset all variables.
+ */
+function drupal_static_reset($name = NULL) {
+  drupal_static($name, NULL, TRUE);
+}
Index: includes/install.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/install.inc,v
retrieving revision 1.86
diff -u -p -r1.86 install.inc
--- includes/install.inc	1 Mar 2009 09:32:17 -0000	1.86
+++ includes/install.inc	22 Mar 2009 19:40:25 -0000
@@ -335,7 +335,8 @@ abstract class DatabaseInstaller {
  */
 function drupal_rewrite_settings($settings = array(), $prefix = '') {
   $default_settings = 'sites/default/default.settings.php';
-  $settings_file = conf_path(FALSE, TRUE) . '/' . $prefix . 'settings.php';
+  drupal_static_reset('conf_path');
+  $settings_file = conf_path(FALSE) . '/' . $prefix . 'settings.php';
 
   // Build list of setting names and insert the values into the global namespace.
   $keys = array();
Index: includes/locale.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/locale.inc,v
retrieving revision 1.207
diff -u -p -r1.207 locale.inc
--- includes/locale.inc	19 Mar 2009 10:48:51 -0000	1.207
+++ includes/locale.inc	22 Mar 2009 19:40:25 -0000
@@ -32,7 +32,8 @@ define('LOCALE_IMPORT_KEEP', 1);
  * User interface for the language overview screen.
  */
 function locale_languages_overview_form() {
-  $languages = language_list('language', TRUE);
+  drupal_static_reset('language');
+  $languages = language_list('language');
 
   $options = array();
   $form['weight'] = array('#tree' => TRUE);
@@ -515,7 +516,8 @@ function locale_languages_configure_form
  * Overview screen for translations.
  */
 function locale_translate_overview_screen() {
-  $languages = language_list('language', TRUE);
+  drupal_static_reset('language_list');
+  $languages = language_list('language');
   $groups = module_invoke_all('locale', 'groups');
 
   // Build headers with all groups in order.
@@ -577,7 +579,8 @@ function locale_translation_filters() {
   $filters = array();
 
   // Get all languages, except English
-  $languages = locale_language_list('name', TRUE);
+  drupal_static_reset('language_list');
+  $languages = locale_language_list('name');
   unset($languages['en']);
 
   $filters['string'] = array(
@@ -699,7 +702,8 @@ function locale_translation_filter_form_
  */
 function locale_translate_import_form() {
   // Get all languages, except English
-  $names = locale_language_list('name', TRUE);
+  drupal_static_reset('language_list');
+  $names = locale_language_list('name');
   unset($names['en']);
 
   if (!count($names)) {
@@ -757,7 +761,8 @@ function locale_translate_import_form_su
   if ($file = file_save_upload('file')) {
 
     // Add language, if not yet supported
-    $languages = language_list('language', TRUE);
+    drupal_static_reset('language_list');
+    $languages = language_list('language');
     $langcode = $form_state['values']['langcode'];
     if (!isset($languages[$langcode])) {
       include_once DRUPAL_ROOT . '/includes/iso.inc';
@@ -796,7 +801,8 @@ function locale_translate_import_form_su
  */
 function locale_translate_export_screen() {
   // Get all languages, except English
-  $names = locale_language_list('name', TRUE);
+  drupal_static_reset('language_list');
+  $names = locale_language_list('name');
   unset($names['en']);
   $output = '';
   // Offer translation export if any language is set up.
