Index: includes/module.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/module.inc,v
retrieving revision 1.174
diff -u -p -r1.174 module.inc
--- includes/module.inc	20 Nov 2009 06:12:45 -0000	1.174
+++ includes/module.inc	20 Nov 2009 20:02:37 -0000
@@ -105,7 +105,7 @@ function system_list($type) {
   $lists = &drupal_static(__FUNCTION__);
 
   // For bootstrap modules, attempt to fetch the list from cache if possible.
-  // if not fetch only the required information to fire bootstrap hooks
+  // If not fetch only the required information to fire bootstrap hooks
   // in case we are going to serve the page from cache.
   if ($type == 'bootstrap') {
     if ($cached = cache_get('bootstrap_modules', 'cache_bootstrap')) {
@@ -126,32 +126,38 @@ function system_list($type) {
   }
   // Otherwise build the list for enabled modules and themes.
   elseif (!isset($lists)) {
-    $lists = array(
-      'module_enabled' => array(),
-      'theme' => array(),
-    );
-    // The module name (rather than the filename) is used as the fallback
-    // weighting in order to guarantee consistent behavior across different
-    // Drupal installations, which might have modules installed in different
-    // locations in the file system. The ordering here must also be
-    // consistent with the one used in module_implements().
-    $result = db_query("SELECT * FROM {system} ORDER BY weight ASC, name ASC");
-    foreach ($result as $record) {
-      if ($record->type == 'module' && $record->status) {
-        // Build a list of all enabled modules.
-        $lists['module_enabled'][$record->name] = $record->name;
-      }
-      // Build a list of themes.
-      if ($record->type == 'theme') {
-        $lists['theme'][$record->name] = $record;
-      }
+    if ($cached = cache_get('system_list', 'cache')) {
+      $lists = $cached->data;
+    }
+    else {
+      $lists = array(
+        'module_enabled' => array(),
+        'theme' => array(),
+      );
+      // The module name (rather than the filename) is used as the fallback
+      // weighting in order to guarantee consistent behavior across different
+      // Drupal installations, which might have modules installed in different
+      // locations in the file system. The ordering here must also be
+      // consistent with the one used in module_implements().
+      $result = db_query("SELECT * FROM {system} ORDER BY weight ASC, name ASC");
+      foreach ($result as $record) {
+        if ($record->type == 'module' && $record->status) {
+          // Build a list of all enabled modules.
+          $lists['module_enabled'][$record->name] = $record->name;
+        }
+        // Build a list of themes.
+        if ($record->type == 'theme') {
+          $lists['theme'][$record->name] = $record;
+        }
 
-      // Additionally prime drupal_get_filename() with the filename and type
-      // for each record, this prevents subsequent database lookups when
-      // drupal_get_filename() is called without the 'file' argument.
-      if ($record->status) {
-        drupal_get_filename($record->type, $record->name, $record->filename);
+        // Additionally prime drupal_get_filename() with the filename and type
+        // for each record, this prevents subsequent database lookups when
+        // drupal_get_filename() is called without the 'file' argument.
+        if ($record->status) {
+          drupal_get_filename($record->type, $record->name, $record->filename);
+        }
       }
+      cache_set('system_list', $lists, 'cache');
     }
   }
 
@@ -163,6 +169,7 @@ function system_list($type) {
  */
 function system_list_reset() {
   drupal_static_reset('system_list');
+  cache_clear_all('system_list', 'cache');
   cache_clear_all('bootstrap_modules', 'cache_bootstrap');
 }
 
