? 422370-45.patch
? jamesan_422370-41.patch
? out
? sites/default/files
? sites/default/settings.php
Index: install.php
===================================================================
RCS file: /cvs/drupal/drupal/install.php,v
retrieving revision 1.177
diff -u -p -r1.177 install.php
--- install.php	6 Jun 2009 16:05:26 -0000	1.177
+++ install.php	7 Jun 2009 03:26:17 -0000
@@ -53,7 +53,8 @@ function install_main() {
   include_once DRUPAL_ROOT . '/includes/session.inc';
   $module_list['system']['filename'] = 'modules/system/system.module';
   $module_list['filter']['filename'] = 'modules/filter/filter.module';
-  module_list(TRUE, FALSE, $module_list);
+  module_list_reset();
+  module_list(FALSE, $module_list);
   drupal_load('module', 'system');
   drupal_load('module', 'filter');
 
Index: update.php
===================================================================
RCS file: /cvs/drupal/drupal/update.php,v
retrieving revision 1.287
diff -u -p -r1.287 update.php
--- update.php	6 Jun 2009 16:05:26 -0000	1.287
+++ update.php	7 Jun 2009 03:26:17 -0000
@@ -755,7 +755,8 @@ if (empty($op) && $update_access_allowed
   include_once DRUPAL_ROOT . '/includes/module.inc';
   $module_list['system']['filename'] = 'modules/system/system.module';
   $module_list['filter']['filename'] = 'modules/filter/filter.module';
-  module_list(TRUE, FALSE, $module_list);
+  module_list_reset();
+  module_list(FALSE, $module_list);
   drupal_load('module', 'system');
   drupal_load('module', 'filter');
 
Index: includes/bootstrap.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/bootstrap.inc,v
retrieving revision 1.286
diff -u -p -r1.286 bootstrap.inc
--- includes/bootstrap.inc	6 Jun 2009 20:15:23 -0000	1.286
+++ includes/bootstrap.inc	7 Jun 2009 03:26:17 -0000
@@ -1596,7 +1596,7 @@ function drupal_get_schema($table = NULL
         // "prime" module_list() here to to values we want, specifically
         // "yes rebuild the list and don't limit to bootstrap".
         // TODO: Remove this call after http://drupal.org/node/222109 is fixed.
-        module_list(TRUE);
+        module_list_reset();
         module_load_all_includes('install');
       }
 
Index: includes/mail.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/mail.inc,v
retrieving revision 1.20
diff -u -p -r1.20 mail.inc
--- includes/mail.inc	7 May 2009 10:41:12 -0000	1.20
+++ includes/mail.inc	7 Jun 2009 03:26:17 -0000
@@ -260,10 +260,7 @@ function drupal_wrap_mail($text, $indent
  */
 function drupal_html_to_text($string, $allowed_tags = NULL) {
   // Cache list of supported tags.
-  static $supported_tags;
-  if (empty($supported_tags)) {
-    $supported_tags = array('a', 'em', 'i', 'strong', 'b', 'br', 'p', 'blockquote', 'ul', 'ol', 'li', 'dl', 'dt', 'dd', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'hr');
-  }
+  static $supported_tags = array('a', 'em', 'i', 'strong', 'b', 'br', 'p', 'blockquote', 'ul', 'ol', 'li', 'dl', 'dt', 'dd', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'hr');
 
   // Make sure only supported tags are kept.
   $allowed_tags = isset($allowed_tags) ? array_intersect($supported_tags, $allowed_tags) : $supported_tags;
@@ -278,7 +275,7 @@ function drupal_html_to_text($string, $a
   // Replace inline <a> tags with the text of link and a footnote.
   // 'See <a href="http://drupal.org">the Drupal site</a>' becomes
   // 'See the Drupal site [1]' with the URL included as a footnote.
-  _drupal_html_to_mail_urls(NULL, TRUE);
+  _drupal_html_to_mail_urls_reset();
   $pattern = '@(<a[^>]+?href="([^"]*)"[^>]*?>(.+?)</a>)@i';
   $string = preg_replace_callback($pattern, '_drupal_html_to_mail_urls', $string);
   $urls = _drupal_html_to_mail_urls();
@@ -432,29 +429,32 @@ function _drupal_wrap_mail_line(&$line, 
  *
  * Keeps track of URLs and replaces them with placeholder tokens.
  */
-function _drupal_html_to_mail_urls($match = NULL, $reset = FALSE) {
+function _drupal_html_to_mail_urls($match = NULL) {
   global $base_url, $base_path;
-  static $urls = array(), $regexp;
+  $urls = &drupal_static(__FUNCTION__, array());
+  $regexp = &drupal_static(__FUNCTION__ . ':regexp', '');
 
-  if ($reset) {
-    // Reset internal URL list.
-    $urls = array();
+  if (empty($regexp)) {
+    $regexp = '@^' . preg_quote($base_path, '@') . '@';
   }
-  else {
-    if (empty($regexp)) {
-      $regexp = '@^' . preg_quote($base_path, '@') . '@';
-    }
-    if ($match) {
-      list(, , $url, $label) = $match;
-      // Ensure all URLs are absolute.
-      $urls[] = strpos($url, '://') ? $url : preg_replace($regexp, $base_url . '/', $url);
-      return $label . ' [' . count($urls) . ']';
-    }
+  if ($match) {
+    list(, , $url, $label) = $match;
+    // Ensure all URLs are absolute.
+    $urls[] = strpos($url, '://') ? $url : preg_replace($regexp, $base_url . '/', $url);
+    return $label . ' [' . count($urls) . ']';
   }
   return $urls;
 }
 
 /**
+ * Reset static variables used by _drupal_html_to_mail_urls().
+ */
+function _drupal_html_to_mail_urls_reset() {
+  drupal_static_reset('_drupal_html_to_mail_urls');
+  drupal_static_reset('_drupal_html_to_mail_urls:regexp');
+}
+
+/**
  * Helper function for drupal_wrap_mail() and drupal_html_to_text().
  *
  * Replace all non-quotation markers from a given piece of indentation with spaces.
Index: includes/module.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/module.inc,v
retrieving revision 1.143
diff -u -p -r1.143 module.inc
--- includes/module.inc	6 Jun 2009 16:05:26 -0000	1.143
+++ includes/module.inc	7 Jun 2009 03:26:17 -0000
@@ -21,7 +21,8 @@ define('MODULE_IMPLEMENTS_CLEAR_CACHE', 
  * Load all the modules that have been enabled in the system table.
  */
 function module_load_all() {
-  foreach (module_list(TRUE) as $module) {
+  module_list_reset();
+  foreach (module_list() as $module) {
     drupal_load('module', $module);
   }
 }
@@ -30,9 +31,6 @@ function module_load_all() {
  * Collect a list of all loaded modules. During the bootstrap, return only
  * vital modules. See bootstrap.inc
  *
- * @param $refresh
- *   Whether to force the module list to be regenerated (such as after the
- *   administrator has changed the system settings).
  * @param $sort
  *   By default, modules are ordered by weight and filename. Set this option to
  *   TRUE to return a module list ordered only by module name.
@@ -43,10 +41,11 @@ function module_load_all() {
  *   An associative array whose keys and values are the names of all loaded
  *   modules.
  */
-function module_list($refresh = FALSE, $sort = FALSE, $fixed_list = NULL) {
-  static $list = array(), $sorted_list;
+function module_list($sort = FALSE, $fixed_list = NULL) {
+  $list = &drupal_static(__FUNCTION__, array());
+  $sorted_list = &drupal_static(__FUNCTION__ . ':sorted_list');
 
-  if (empty($list) || $refresh || $fixed_list) {
+  if (empty($list) || $fixed_list) {
     $list = array();
     $sorted_list = NULL;
     if ($fixed_list) {
@@ -76,6 +75,14 @@ function module_list($refresh = FALSE, $
 }
 
 /**
+ * Reset static variables used by module_list().
+ */
+function module_list_reset() {
+  drupal_static_reset('module_list');
+  drupal_static_reset('module_list:sorted_list');
+}
+
+/**
  * Find dependencies any level deep and fill in required by information too.
  *
  * @param $files
@@ -195,7 +202,7 @@ function module_enable($module_list) {
 
   if (!empty($invoke_modules)) {
     // Refresh the module list to include the new enabled module.
-    module_list(TRUE);
+    module_list_reset();
     // Force to regenerate the stored list of hook implementations.
     registry_rebuild();
   }
@@ -250,7 +257,7 @@ function module_disable($module_list) {
     // so we can still call module hooks to get information.
     module_invoke_all('modules_disabled', $invoke_modules);
     // Refresh the module list to exclude the disabled modules.
-    module_list(TRUE);
+    module_list_reset();
     // Force to regenerate the stored list of hook implementations.
     registry_rebuild();
   }
@@ -323,7 +330,10 @@ function module_hook($module, $hook) {
  *   the implementations are loaded as necessary.
  */
 function module_implements($hook, $sort = FALSE) {
-  static $implementations = array(), $sorted_implementations = array(), $loaded = array(), $cached_hooks = 0;
+  $implementations = &drupal_static(__FUNCTION__, array());
+  $sorted_implementations = &drupal_static(__FUNCTION__ . ':sorted_implementations', array());
+  $loaded = &drupal_static(__FUNCTION__ . ':loaded', array());
+  $cached_hooks = &drupal_static(__FUNCTION__ . ':cached_hooks', 0);
 
   if (defined('MAINTENANCE_MODE')) {
     return _module_implements_maintenance($hook, $sort);
Index: includes/pager.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/pager.inc,v
retrieving revision 1.67
diff -u -p -r1.67 pager.inc
--- includes/pager.inc	12 May 2009 18:26:41 -0000	1.67
+++ includes/pager.inc	7 Jun 2009 03:26:17 -0000
@@ -231,7 +231,7 @@ function pager_query($query, $limit = 10
  *   except for those pertaining to paging.
  */
 function pager_get_querystring() {
-  static $string = NULL;
+  $string = &drupal_static(__FUNCTION__);
   if (!isset($string)) {
     $string = drupal_query_string_encode($_REQUEST, array_merge(array('q', 'page'), array_keys($_COOKIE)));
   }
@@ -527,6 +527,7 @@ function theme_pager_link($text, $page_n
 
   // Set each pager link title
   if (!isset($attributes['title'])) {
+    // $titles does not use drupal_static as its value never changes.
     static $titles = NULL;
     if (!isset($titles)) {
       $titles = array(
Index: includes/theme.maintenance.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/theme.maintenance.inc,v
retrieving revision 1.30
diff -u -p -r1.30 theme.maintenance.inc
--- includes/theme.maintenance.inc	6 Jun 2009 16:05:26 -0000	1.30
+++ includes/theme.maintenance.inc	7 Jun 2009 03:26:17 -0000
@@ -39,7 +39,8 @@ function _drupal_maintenance_theme() {
     // Load module basics (needed for hook invokes).
     $module_list['system']['filename'] = 'modules/system/system.module';
     $module_list['filter']['filename'] = 'modules/filter/filter.module';
-    module_list(TRUE, FALSE, $module_list);
+    module_list_reset();
+    module_list(FALSE, $module_list);
     drupal_load('module', 'system');
     drupal_load('module', 'filter');
 
Index: modules/simpletest/drupal_web_test_case.php
===================================================================
RCS file: /cvs/drupal/drupal/modules/simpletest/drupal_web_test_case.php,v
retrieving revision 1.113
diff -u -p -r1.113 drupal_web_test_case.php
--- modules/simpletest/drupal_web_test_case.php	4 Jun 2009 03:33:28 -0000	1.113
+++ modules/simpletest/drupal_web_test_case.php	7 Jun 2009 03:26:17 -0000
@@ -1103,7 +1103,7 @@ class DrupalWebTestCase extends DrupalTe
 
       // Reload module list and implementations to ensure that test module hooks
       // aren't called after tests.
-      module_list(TRUE);
+      module_list_reset();
       module_implements(MODULE_IMPLEMENTS_CLEAR_CACHE);
 
       // Reset the Field API.
Index: modules/simpletest/tests/module.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/simpletest/tests/module.test,v
retrieving revision 1.4
diff -u -p -r1.4 module.test
--- modules/simpletest/tests/module.test	30 May 2009 11:17:32 -0000	1.4
+++ modules/simpletest/tests/module.test	7 Jun 2009 03:26:17 -0000
@@ -43,7 +43,7 @@ class ModuleUnitTest extends DrupalWebTe
       ->condition('type', 'module')
       ->execute();
     // Reset the module list.
-    module_list(TRUE);
+    module_list_reset();
     // Move path at the end of the array.
     unset($base_module_list['path']);
     $base_module_list['path'] = 'path';
@@ -54,12 +54,12 @@ class ModuleUnitTest extends DrupalWebTe
       'system' => array('filename' => drupal_get_path('module', 'system')),
       'menu' => array('filename' => drupal_get_path('module', 'menu')),
     );
-    module_list(FALSE, FALSE, $fixed_list);
+    module_list(FALSE, $fixed_list);
     $new_module_list = array_combine(array_keys($fixed_list), array_keys($fixed_list));
     $this->assertModuleList($new_module_list, t('When using a fixed list'));
 
     // Reset the module list.
-    module_list(TRUE);
+    module_list_reset();
     $this->assertModuleList($base_module_list, t('After reset'));
   }
 
@@ -72,6 +72,6 @@ class ModuleUnitTest extends DrupalWebTe
   protected function assertModuleList(Array $expected_values, $condition) {
     $this->assertIdentical($expected_values, module_list(), t('@condition: module_list() returns correct results', array('@condition' => $condition)));
     ksort($expected_values);
-    $this->assertIdentical($expected_values, module_list(FALSE, TRUE), t('@condition: module_list() returns correctly sorted results', array('@condition' => $condition)));
+    $this->assertIdentical($expected_values, module_list(TRUE), t('@condition: module_list() returns correctly sorted results', array('@condition' => $condition)));
   }
 }
Index: modules/system/system.admin.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.admin.inc,v
retrieving revision 1.154
diff -u -p -r1.154 system.admin.inc
--- modules/system/system.admin.inc	6 Jun 2009 16:05:27 -0000	1.154
+++ modules/system/system.admin.inc	7 Jun 2009 03:26:17 -0000
@@ -926,7 +926,8 @@ function system_modules_submit($form, &$
     drupal_install_modules($new_modules);
   }
 
-  $current_module_list = module_list(TRUE);
+  module_list_reset();
+  $current_module_list = module_list();
   if ($old_module_list != $current_module_list) {
     drupal_set_message(t('The configuration options have been saved.'));
   }
Index: modules/system/system.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.test,v
retrieving revision 1.46
diff -u -p -r1.46 system.test
--- modules/system/system.test	27 May 2009 18:34:01 -0000	1.46
+++ modules/system/system.test	7 Jun 2009 03:26:17 -0000
@@ -41,7 +41,7 @@ class ModuleTestCase extends DrupalWebTe
    *   Expected module state.
    */
   function assertModules(array $modules, $enabled) {
-    module_list(TRUE);
+    module_list_reset();
     foreach ($modules as $module) {
       if ($enabled) {
         $message = 'Module "@module" is enabled.';
