diff --git a/includes/bootstrap.inc b/includes/bootstrap.inc index d37a98e..7b8a9d1 100644 --- a/includes/bootstrap.inc +++ b/includes/bootstrap.inc @@ -2879,8 +2879,10 @@ function &drupal_static($name, $default_value = NULL, $reset = FALSE) { // Reset all: ($name == NULL). This needs to be done one at a time so that // references returned by earlier invocations of drupal_static() also get // reset. - foreach ($default as $name => $value) { - $data[$name] = $value; + if ($reset) { + foreach ($default as $name => $value) { + $data[$name] = $value; + } } // As the function returns a reference, the return should always be a // variable. diff --git a/includes/common.inc b/includes/common.inc index d0649d7..78e018a 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -1856,12 +1856,9 @@ function format_interval($timestamp, $granularity = 2, $langcode = NULL) { * A translated date string in the requested format. */ function format_date($timestamp, $type = 'medium', $format = '', $timezone = NULL, $langcode = NULL) { - // Use the advanced drupal_static() pattern, since this is called very often. - static $drupal_static_fast; - if (!isset($drupal_static_fast)) { - $drupal_static_fast['timezones'] = &drupal_static(__FUNCTION__); - } - $timezones = &$drupal_static_fast['timezones']; + // Internal PHP time zone information is not expected to change within a + // single request. + static $timezones; if (!isset($timezone)) { $timezone = date_default_timezone_get(); @@ -6936,7 +6933,8 @@ function drupal_write_record($table, &$record, $primary_keys = array()) { * @see drupal_parse_info_format() */ function drupal_parse_info_file($filename) { - $info = &drupal_static(__FUNCTION__, array()); + // .info files on disc should not change within a single request. + static $info = array(); if (!isset($info[$filename])) { if (!file_exists($filename)) { diff --git a/includes/form.inc b/includes/form.inc index 23636d0..82d4bcb 100644 --- a/includes/form.inc +++ b/includes/form.inc @@ -2431,9 +2431,9 @@ function form_set_value($element, $value, &$form_state) { * An array with all hierarchical elements flattened to a single array. */ function form_options_flatten($array) { - // Always reset static var when first entering the recursion. - drupal_static_reset('_form_options_flatten'); - return _form_options_flatten($array); + $flat = array(); + _form_options_flatten($array, $flat); + return $flat; } /** @@ -2443,22 +2443,18 @@ function form_options_flatten($array) { * array that has removed duplicate keys. Also handles cases where objects * are passed as array values. */ -function _form_options_flatten($array) { - $return = &drupal_static(__FUNCTION__); - +function _form_options_flatten($array, &$return) { foreach ($array as $key => $value) { if (is_object($value)) { - _form_options_flatten($value->option); + _form_options_flatten($value->option, $return); } elseif (is_array($value)) { - _form_options_flatten($value); + _form_options_flatten($value, $return); } else { $return[$key] = 1; } } - - return $return; } /**