Index: includes/theme.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/theme.inc,v
retrieving revision 1.399
diff -u -p -r1.399 theme.inc
--- includes/theme.inc	30 Nov 2007 16:10:28 -0000	1.399
+++ includes/theme.inc	30 Nov 2007 16:19:24 -0000
@@ -406,17 +406,22 @@ function _theme_build_registry($theme, $
  *   An array of the currently available themes.
  */
 function list_themes($refresh = FALSE) {
-  static $list = array();
+  static $list = array(), $db_is_active;
 
   if ($refresh) {
     $list = array();
   }
+  if (!isset($db_is_active)) {
+    // Also check if system table exists to allow flawless installation via
+    // install.php if settings are configured but database is empty.
+    $db_is_active = db_is_active() && db_table_exists('system');
+  }
 
   if (empty($list)) {
     $list = array();
     $themes = array();
     // Extract from the database only when it is available.
-    if (db_is_active() && db_table_exists('system')) {
+    if ($db_is_active) {
       $result = db_query("SELECT * FROM {system} WHERE type = '%s'", 'theme');
       while ($theme = db_fetch_object($result)) {
         if (file_exists($theme->filename)) {
