Index: includes/theme.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/theme.inc,v
retrieving revision 1.497
diff -u -p -r1.497 theme.inc
--- includes/theme.inc	2 Jul 2009 04:27:22 -0000	1.497
+++ includes/theme.inc	9 Jul 2009 19:00:27 -0000
@@ -196,6 +196,7 @@ function _init_theme($theme, $base_theme
 
 /**
  * Get the theme registry.
+ *
  * @return
  *   The theme registry array if it has been stored in memory, NULL otherwise.
  */
@@ -205,13 +206,14 @@ function theme_get_registry() {
 
 /**
  * Store the theme registry in memory.
+ *
  * @param $registry
  *   A registry array as returned by _theme_build_registry()
  * @return
  *   The theme registry array stored in memory
  */
 function _theme_set_registry($registry = NULL) {
-  static $theme_registry = NULL;
+  $theme_registry = &drupal_static(__FUNCTION__);
 
   if (isset($registry)) {
     $theme_registry = $registry;
@@ -486,8 +488,6 @@ function _theme_build_registry($theme, $
  * Retrieved from the database, if available and the site is not in maintenance
  * mode; otherwise compiled freshly from the filesystem.
  *
- * @param $refresh
- *   Whether to reload the list of themes from the database. Defaults to FALSE.
  * @return
  *   An associative array of the currently available themes. The keys are the
  *   names of the themes and the values are objects having the following
@@ -505,12 +505,8 @@ function _theme_build_registry($theme, $
  *   - 'engine': The name of the theme engine.
  *   - 'base theme': The name of the base theme.
  */
-function list_themes($refresh = FALSE) {
-  static $list = array();
-
-  if ($refresh) {
-    $list = array();
-  }
+function list_themes() {
+  $list = &drupal_static(__FUNCTION__, array());
 
   if (empty($list)) {
     $list = array();
@@ -688,7 +684,7 @@ function theme() {
   $args = func_get_args();
   $hook = array_shift($args);
 
-  static $hooks = NULL;
+  $hooks = &drupal_static(__FUNCTION__);
   if (!isset($hooks)) {
     init_theme();
     $hooks = theme_get_registry();
@@ -888,7 +884,6 @@ function path_to_theme() {
  *   The existing cache of theme hooks to test against.
  * @param $prefixes
  *   An array of prefixes to test, in reverse order of importance.
- *
  * @return $templates
  *   The functions found, suitable for returning from hook_theme;
  */
@@ -1031,7 +1026,6 @@ function drupal_find_theme_templates($ca
  *
  * @param $key
  *  The template/style value for a given theme.
- *
  * @return
  *   An associative array containing theme settings.
  */
@@ -1074,22 +1068,18 @@ function theme_get_settings($key = NULL)
  * This function is designed for use from within themes & engines
  * to determine theme settings made in the admin interface.
  *
- * Caches values for speed (use $refresh = TRUE to refresh cache)
+ * Caches values for speed.
  *
  * @param $setting_name
  *  The name of the setting to be retrieved.
- *
- * @param $refresh
- *  Whether to reload the cache of settings.
- *
  * @return
  *   The value of the requested setting, NULL if the setting does not exist.
  */
-function theme_get_setting($setting_name, $refresh = FALSE) {
+function theme_get_setting($setting_name) {
   global $theme_key;
-  static $settings;
+  $settings = &drupal_static(__FUNCTION__);
 
-  if (empty($settings) || $refresh) {
+  if (empty($settings)) {
     $settings = theme_get_settings($theme_key);
 
     $themes = list_themes();
@@ -1133,7 +1123,6 @@ function theme_get_setting($setting_name
  *   anything stored in $variables['template_file'] if using a variable processor hook.
  * @param $variables
  *   A keyed array of variables that will appear in the output.
- *
  * @return
  *   The output generated by the template.
  */
@@ -1229,7 +1218,6 @@ function theme_placeholder($text) {
  *
  * @param $display
  *   (optional) Set to 'status' or 'error' to display only messages of that type.
- *
  * @return
  *   A string containing the messages.
  */
@@ -1348,7 +1336,8 @@ function theme_image($path, $alt = '', $
  *
  * @param $breadcrumb
  *   An array containing the breadcrumb links.
- * @return a string containing the breadcrumb output.
+ * @return
+ *   A string containing the breadcrumb output.
  */
 function theme_breadcrumb($breadcrumb) {
   if (!empty($breadcrumb)) {
@@ -1837,7 +1826,7 @@ function _theme_table_cell($cell, $heade
  */
 function template_preprocess(&$variables, $hook) {
   global $user;
-  static $count = array();
+  $count = &drupal_static(__FUNCTION__, array());
 
   // Track run count for each hook to provide zebra striping.
   // See "template_preprocess_block()" which provides the same feature specific to blocks.
@@ -2021,7 +2010,6 @@ function template_process_page(&$variabl
  *
  * @param $args
  *   An array of path arguments, such as from function arg().
- *
  * @return
  *   An array of suggested template files.
  */
Index: includes/unicode.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/unicode.inc,v
retrieving revision 1.39
diff -u -p -r1.39 unicode.inc
--- includes/unicode.inc	24 May 2009 17:39:30 -0000	1.39
+++ includes/unicode.inc	9 Jul 2009 19:00:27 -0000
@@ -325,7 +325,7 @@ function _mime_header_decode($matches) {
  *   array('<', '&', '"'). This affects both named and numerical entities.
  */
 function decode_entities($text, $exclude = array()) {
-  static $html_entities;
+  $html_entities = &drupal_static(__FUNCTION__);
   if (!isset($html_entities)) {
     include DRUPAL_ROOT . '/includes/unicode.entities.inc';
   }
Index: includes/xmlrpc.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/xmlrpc.inc,v
retrieving revision 1.58
diff -u -p -r1.58 xmlrpc.inc
--- includes/xmlrpc.inc	15 Jun 2009 10:10:46 -0000	1.58
+++ includes/xmlrpc.inc	9 Jul 2009 19:00:27 -0000
@@ -191,7 +191,7 @@ function xmlrpc_message_parse($xmlrpc_me
  *   The most recently stored $xmlrpc_message
  */
 function xmlrpc_message_set($value = NULL) {
-  static $xmlrpc_message;
+  $xmlrpc_message = &drupal_static(__FUNCTION__);
   if ($value) {
     $xmlrpc_message = $value;
   }
@@ -343,7 +343,7 @@ EOD;
 
 
 function xmlrpc_error($code = NULL, $message = NULL) {
-  static $xmlrpc_error;
+  $xmlrpc_error = &drupal_static(__FUNCTION__);
   if (isset($code)) {
     $xmlrpc_error = new stdClass();
     $xmlrpc_error->is_error = TRUE;
Index: modules/system/system.admin.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.admin.inc,v
retrieving revision 1.159
diff -u -p -r1.159 system.admin.inc
--- modules/system/system.admin.inc	8 Jul 2009 07:53:16 -0000	1.159
+++ modules/system/system.admin.inc	9 Jul 2009 19:00:27 -0000
@@ -293,7 +293,7 @@ function system_themes_form_submit($form
     $new_theme_list = array('garland');
   }
 
-  list_themes(TRUE);
+  drupal_static_reset('list_themes');
   menu_rebuild();
   drupal_theme_rebuild();
   drupal_set_message(t('The configuration options have been saved.'));
