Index: includes/bootstrap.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/bootstrap.inc,v
retrieving revision 1.321
diff -u -p -r1.321 bootstrap.inc
--- includes/bootstrap.inc	5 Nov 2009 03:00:21 -0000	1.321
+++ includes/bootstrap.inc	5 Nov 2009 16:51:25 -0000
@@ -2074,12 +2074,18 @@ function registry_rebuild() {
 function &drupal_static($name, $default_value = NULL, $reset = FALSE) {
   static $data = array();
 
-  // Reset a single value, or all values.
+  // Reset a single value, or all values. Before cleaning up $data, set the
+  // individual data item(s) to NULL, so that the function that called
+  // drupal_static() to begin with gets its referenced copy reset as well.
   if ($reset) {
     if (isset($name)) {
+      $data[$name] = NULL;
       unset($data[$name]);
     }
     else {
+      foreach (array_keys($data) as $name) {
+        $data[$name] = NULL;
+      }
       $data = array();
     }
     // We must return a reference to a variable.
Index: includes/common.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/common.inc,v
retrieving revision 1.1041
diff -u -p -r1.1041 common.inc
--- includes/common.inc	5 Nov 2009 16:19:25 -0000	1.1041
+++ includes/common.inc	5 Nov 2009 16:51:26 -0000
@@ -2275,7 +2275,10 @@ function format_interval($timestamp, $gr
  *   A translated date string in the requested format.
  */
 function format_date($timestamp, $type = 'medium', $format = '', $timezone = NULL, $langcode = NULL) {
-  $timezones = &drupal_static(__FUNCTION__, array());
+  static $drupal_static = array();
+  isset($drupal_static[__FUNCTION__]) || ($drupal_static[__FUNCTION__] = &drupal_static(__FUNCTION__));
+  $timezones = &$drupal_static[__FUNCTION__];
+
   if (!isset($timezone)) {
     global $user;
     if (variable_get('configurable_timezones', 1) && $user->uid && $user->timezone) {
@@ -2512,7 +2515,9 @@ function url($path = NULL, array $option
   }
 
   global $base_url, $base_secure_url, $base_insecure_url;
-  $script = &drupal_static(__FUNCTION__);
+  static $drupal_static = array();
+  isset($drupal_static[__FUNCTION__]) || ($drupal_static[__FUNCTION__] = &drupal_static(__FUNCTION__));
+  $script = &$drupal_static[__FUNCTION__];
 
   if (!isset($script)) {
     // On some web servers, such as IIS, we can't omit "index.php". So, we
@@ -4700,7 +4705,9 @@ function drupal_system_listing($mask, $d
  *   keyed array as described above.
  */
 function drupal_alter($type, &$data, &$context1 = NULL, &$context2 = NULL) {
-  $functions = &drupal_static(__FUNCTION__, array());
+  static $drupal_static = array();
+  isset($drupal_static[__FUNCTION__]) || ($drupal_static[__FUNCTION__] = &drupal_static(__FUNCTION__));
+  $functions = &$drupal_static[__FUNCTION__];
 
   // Some alter hooks are invoked many times per page request, so statically
   // cache the list of functions to call, and on subsequent calls, iterate
@@ -6191,8 +6198,9 @@ function drupal_check_incompatibility($v
  *   to return an array with info about all types.
  */
 function entity_get_info($entity_type = NULL) {
-  // We statically cache the information returned by hook_entity_info().
-  $entity_info = &drupal_static(__FUNCTION__, array());
+  static $drupal_static = array();
+  isset($drupal_static[__FUNCTION__]) || ($drupal_static[__FUNCTION__] = &drupal_static(__FUNCTION__));
+  $entity_info = &$drupal_static[__FUNCTION__];
 
   if (empty($entity_info)) {
     if ($cache = cache_get('entity_info')) {
Index: includes/module.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/module.inc,v
retrieving revision 1.165
diff -u -p -r1.165 module.inc
--- includes/module.inc	5 Nov 2009 16:19:25 -0000	1.165
+++ includes/module.inc	5 Nov 2009 16:51:26 -0000
@@ -367,7 +367,9 @@ function module_hook($module, $hook) {
  * @see module_implements_write_cache().
  */
 function module_implements($hook, $sort = FALSE, $reset = FALSE) {
-  $implementations = &drupal_static(__FUNCTION__, array());
+  static $drupal_static = array();
+  isset($drupal_static[__FUNCTION__]) || ($drupal_static[__FUNCTION__] = &drupal_static(__FUNCTION__));
+  $implementations = &$drupal_static[__FUNCTION__];
 
   // We maintain a persistent cache of hook implementations in addition to the
   // static cache to avoid looping through every module and every hook on each
Index: includes/path.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/path.inc,v
retrieving revision 1.47
diff -u -p -r1.47 path.inc
--- includes/path.inc	24 Oct 2009 05:13:43 -0000	1.47
+++ includes/path.inc	5 Nov 2009 16:51:26 -0000
@@ -45,14 +45,20 @@ function drupal_path_initialize() {
  */
 function drupal_lookup_path($action, $path = '', $path_language = '') {
   global $language;
-  $cache = &drupal_static(__FUNCTION__, array(
-    'map' => array(),
-    'no_source' => array(),
-    'whitelist' => NULL,
-    'system_paths' => array(),
-    'no_aliases' => array(),
-    'first_call' => TRUE,
-  ));
+  static $drupal_static = array();
+  isset($drupal_static[__FUNCTION__]) || ($drupal_static[__FUNCTION__] = &drupal_static(__FUNCTION__));
+  $cache = &$drupal_static[__FUNCTION__];
+
+  if (!isset($cache)) {
+    $cache = array(
+      'map' => array(),
+      'no_source' => array(),
+      'whitelist' => NULL,
+      'system_paths' => array(),
+      'no_aliases' => array(),
+      'first_call' => TRUE,
+    );
+  }
 
   // Retrieve the path alias whitelist.
   if (!isset($cache['whitelist'])) {
@@ -245,7 +251,9 @@ function drupal_get_normal_path($path, $
  *   not found.
  */
 function arg($index = NULL, $path = NULL) {
-  $arguments = &drupal_static(__FUNCTION__);
+  static $drupal_static = array();
+  isset($drupal_static[__FUNCTION__]) || ($drupal_static[__FUNCTION__] = &drupal_static(__FUNCTION__));
+  $arguments = &$drupal_static[__FUNCTION__];
 
   if (!isset($path)) {
     $path = $_GET['q'];
@@ -310,7 +318,9 @@ function drupal_set_title($title = NULL,
  *   Boolean value: TRUE if the current page is the front page; FALSE if otherwise.
  */
 function drupal_is_front_page() {
-  $is_front_page = &drupal_static(__FUNCTION__);
+  static $drupal_static = array();
+  isset($drupal_static[__FUNCTION__]) || ($drupal_static[__FUNCTION__] = &drupal_static(__FUNCTION__));
+  $is_front_page = &$drupal_static[__FUNCTION__];
 
   if (!isset($is_front_page)) {
     // As drupal_path_initialize updates $_GET['q'] with the 'site_frontpage' path,
Index: modules/user/user.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/user/user.module,v
retrieving revision 1.1075
diff -u -p -r1.1075 user.module
--- modules/user/user.module	1 Nov 2009 21:26:44 -0000	1.1075
+++ modules/user/user.module	5 Nov 2009 16:51:29 -0000
@@ -673,7 +673,9 @@ function user_role_permissions($roles = 
  */
 function user_access($string, $account = NULL) {
   global $user;
-  $perm = &drupal_static(__FUNCTION__, array());
+  static $drupal_static = array();
+  isset($drupal_static[__FUNCTION__]) || ($drupal_static[__FUNCTION__] = &drupal_static(__FUNCTION__));
+  $perm = &$drupal_static[__FUNCTION__];
 
   if (!isset($account)) {
     $account = $user;
