Index: includes/module.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/module.inc,v
retrieving revision 1.168
diff -u -p -r1.168 module.inc
--- includes/module.inc	8 Nov 2009 18:49:04 -0000	1.168
+++ includes/module.inc	8 Nov 2009 19:30:05 -0000
@@ -70,7 +70,7 @@ function module_list($refresh = FALSE, $
         $list = system_list('bootstrap');
       }
       else {
-        $list = system_list('module');
+        $list = system_list('module_enabled');
       }
     }
   }
@@ -101,31 +101,47 @@ function system_list($type) {
   $lists = &drupal_static(__FUNCTION__);
 
   if (!isset($lists)) {
-    $lists = array('bootstrap' => array(), 'module' => array(), 'theme' => array());
+    $lists = array(
+      'bootstrap' => array(),
+      'module' => array(),
+      'module_enabled' => array(),
+      'theme' => array(),
+      'theme_enabled' => 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} WHERE status = 1 ORDER BY weight ASC, name ASC");
+    $result = db_query("SELECT * FROM {system} ORDER BY weight ASC, name ASC");
     foreach ($result as $record) {
-      // Build a list of all enabled modules.
+      // Build a list of all modules.
       if ($record->type == 'module') {
         $lists['module'][$record->name] = $record->name;
-        // Build a separate array of modules required for bootstrap.
-        if ($record->bootstrap) {
-          $lists['bootstrap'][$record->name] = $record->name;
+        // Build a list of all enabled modules.
+        if ($record->status) {
+          $lists['module_enabled'][$record->name] = $record->name;
+          // Build a separate array of modules required for bootstrap.
+          if ($record->bootstrap) {
+            $lists['bootstrap'][$record->name] = $record->name;
+          }
         }
       }
-      // Build a list of enabled themes.
+      // Build a list of themes.
       if ($record->type == 'theme') {
         $lists['theme'][$record->name] = $record;
+        // Build a list of enabled themes.
+        if ($record->status) {
+          $lists['theme_enabled'][$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.
-      drupal_get_filename($record->type, $record->name, $record->filename);
+      if ($record->status) {
+        drupal_get_filename($record->type, $record->name, $record->filename);
+      }
     }
   }
 
Index: modules/system/system.install
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.install,v
retrieving revision 1.417
diff -u -p -r1.417 system.install
--- modules/system/system.install	8 Nov 2009 09:29:07 -0000	1.417
+++ modules/system/system.install	8 Nov 2009 19:28:36 -0000
@@ -1567,7 +1567,7 @@ function system_schema() {
     ),
     'primary key' => array('filename'),
     'indexes' => array(
-      'system_list' => array('status', 'weight', 'name'),
+      'system_list' => array('weight', 'name'),
       'type_name' => array('type', 'name'),
     ),
   );
@@ -2203,7 +2203,7 @@ function system_update_7018() {
   db_drop_index('system', 'bootstrap');
   db_change_field('system', 'type', 'type', array('type' => 'varchar', 'length' => 12, 'not null' => TRUE, 'default' => ''));
   db_add_index('system', 'type_name', array('type', 'name'));
-  db_add_index('system', 'system_list', array('status', 'weight', 'name'));
+  db_add_index('system', 'system_list', array('weight', 'name'));
 }
 
 /**
