Index: includes/common.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/common.inc,v
retrieving revision 1.909
diff -u -p -r1.909 common.inc
--- includes/common.inc	22 May 2009 03:19:42 -0000	1.909
+++ includes/common.inc	24 May 2009 01:49:18 -0000
@@ -3557,7 +3557,6 @@ function drupal_common_theme() {
       'arguments' => array('content' => NULL, 'show_blocks' => TRUE, 'show_messages' => TRUE),
       'template' => 'maintenance-page',
       'path' => 'includes',
-      'file' => 'theme.maintenance.inc',
     ),
     'update_page' => array(
       'arguments' => array('content' => NULL, 'show_messages' => TRUE),
Index: includes/file.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/file.inc,v
retrieving revision 1.168
diff -u -p -r1.168 file.inc
--- includes/file.inc	17 May 2009 10:42:16 -0000	1.168
+++ includes/file.inc	24 May 2009 02:00:29 -0000
@@ -1427,6 +1427,7 @@ function file_scan_directory($dir, $mask
           // Always use this match over anything already set in $files with the
           // same $$options['key'].
           $file = (object) array(
+            'path' => $dir,
             'filepath' => $filepath,
             'filename' => $filename,
             'name' => pathinfo($filename, PATHINFO_FILENAME),
Index: includes/theme.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/theme.inc,v
retrieving revision 1.489
diff -u -p -r1.489 theme.inc
--- includes/theme.inc	22 May 2009 11:34:05 -0000	1.489
+++ includes/theme.inc	24 May 2009 01:49:18 -0000
@@ -311,7 +311,7 @@ function drupal_theme_rebuild() {
 function _theme_process_registry(&$cache, $name, $type, $theme, $path) {
   $result = array();
   $function = $name . '_theme';
-  if (function_exists($function)) {
+  if (drupal_function_exists($function)) {
     $result = $function($cache, $type, $theme, $path);
 
     foreach ($result as $hook => $info) {
@@ -322,18 +322,6 @@ function _theme_process_registry(&$cache
       if (!isset($info['template']) && !isset($info['function'])) {
         $result[$hook]['function'] = ($type == 'module' ? 'theme_' : $name . '_') . $hook;
       }
-      // If a path is set in the info, use what was set. Otherwise use the
-      // default path. This is mostly so system.module can declare theme
-      // functions on behalf of core .include files.
-      // All files are included to be safe. Conditionally included
-      // files can prevent them from getting registered.
-      if (isset($info['file']) && !isset($info['path'])) {
-        $result[$hook]['file'] = $path . '/' . $info['file'];
-        include_once DRUPAL_ROOT . '/' . $result[$hook]['file'];
-      }
-      elseif (isset($info['file']) && isset($info['path'])) {
-        include_once DRUPAL_ROOT . '/' . $info['path'] . '/' . $info['file'];
-      }
 
       if (isset($info['template']) && !isset($info['path'])) {
         $result[$hook]['template'] = $path . '/' . $info['template'];
@@ -376,10 +364,10 @@ function _theme_process_registry(&$cache
         }
 
         foreach ($prefixes as $prefix) {
-          if (function_exists($prefix . '_preprocess')) {
+          if (drupal_function_exists($prefix . '_preprocess')) {
             $info['preprocess functions'][] = $prefix . '_preprocess';
           }
-          if (function_exists($prefix . '_preprocess_' . $hook)) {
+          if (drupal_function_exists($prefix . '_preprocess_' . $hook)) {
             $info['preprocess functions'][] = $prefix . '_preprocess_' . $hook;
           }
         }
@@ -408,10 +396,10 @@ function _theme_process_registry(&$cache
         if (!isset($info['preprocess functions'])) {
           $cache[$hook]['preprocess functions'] = array();
         }
-        if (function_exists($name . '_preprocess')) {
+        if (drupal_function_exists($name . '_preprocess')) {
           $cache[$hook]['preprocess functions'][] = $name . '_preprocess';
         }
-        if (function_exists($name . '_preprocess_' . $hook)) {
+        if (drupal_function_exists($name . '_preprocess_' . $hook)) {
           $cache[$hook]['preprocess functions'][] = $name . '_preprocess_' . $hook;
         }
         // Ensure uniqueness.
@@ -659,14 +647,6 @@ function theme() {
   // point path_to_theme() to the currently used theme path:
   $theme_path = $info['theme path'];
 
-  // Include a file if the theme function or preprocess function is held elsewhere.
-  if (!empty($info['file'])) {
-    $include_file = $info['file'];
-    if (isset($info['path'])) {
-      $include_file = $info['path'] . '/' . $include_file;
-    }
-    include_once DRUPAL_ROOT . '/' . $include_file;
-  }
   if (isset($info['function'])) {
     // The theme call is a function.
     if (drupal_function_exists($info['function'])) {
Index: includes/theme.maintenance.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/theme.maintenance.inc,v
retrieving revision 1.28
diff -u -p -r1.28 theme.maintenance.inc
--- includes/theme.maintenance.inc	21 May 2009 21:12:22 -0000	1.28
+++ includes/theme.maintenance.inc	24 May 2009 02:16:19 -0000
@@ -31,18 +31,32 @@ function _drupal_maintenance_theme() {
   require_once DRUPAL_ROOT . '/includes/database/database.inc';
   unicode_check();
 
+  // Load maintenance mode modules along with their include files.
+  $includes = array();
+  foreach (drupal_maintenance_modules() as $module => $info) {
+    foreach ($info['files'] as $file) {
+      if ($file == $module . '.module') {
+        $module_list[$module]['filename'] = $info['path'] . '/' . $file;
+      }
+      else {
+        $includes[] = $info['path'] . '/' . $file;
+      }
+    }
+  }
+  // .module files need to be loaded first.
+  module_list(TRUE, FALSE, $module_list);
+  foreach ($module_list as $module => $info) {
+    drupal_load('module', $module);
+  }
+  foreach ($includes as $file) {
+    include_once DRUPAL_ROOT . '/' . $file;
+  }
+
   // Install and update pages are treated differently to prevent theming overrides.
   if (defined('MAINTENANCE_MODE') && (MAINTENANCE_MODE == 'install' || MAINTENANCE_MODE == 'update')) {
     $theme = 'minnelli';
   }
   else {
-    // 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);
-    drupal_load('module', 'system');
-    drupal_load('module', 'filter');
-
     $theme = variable_get('maintenance_theme', 'minnelli');
   }
 
@@ -70,6 +84,30 @@ function _drupal_maintenance_theme() {
 }
 
 /**
+ * Determine modules to load in maintenance mode.
+ *
+ * All modules defining
+ * @code
+ * maintenance = TRUE
+ * @endcode
+ * in their respective .info file are loaded in maintenance mode.
+ */
+function drupal_maintenance_modules() {
+  $files = drupal_system_listing('/\.info$/', 'modules', 'name', 0);
+  $required = array();
+  foreach ($files as $name => $file) {
+    $info = drupal_parse_info_file($file->filepath);
+    if (!empty($info) && !empty($info['maintenance']) && $info['maintenance']) {
+      // Additionally set path to module, since drupal_get_path() depends on
+      // the database, which might not be available.
+      $info['path'] = $file->path;
+      $required[$name] = $info;
+    }
+  }
+  return $required;
+}
+
+/**
  * This builds the registry when the site needs to bypass any database calls.
  */
 function _theme_load_offline_registry($theme, $base_theme = NULL, $theme_engine = NULL) {
Index: modules/aggregator/aggregator.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/aggregator/aggregator.module,v
retrieving revision 1.410
diff -u -p -r1.410 aggregator.module
--- modules/aggregator/aggregator.module	21 May 2009 23:07:14 -0000	1.410
+++ modules/aggregator/aggregator.module	22 May 2009 04:46:35 -0000
@@ -36,16 +36,13 @@ function aggregator_theme() {
   return array(
     'aggregator_wrapper' => array(
       'arguments' => array('content' => NULL),
-      'file' => 'aggregator.pages.inc',
       'template' => 'aggregator-wrapper',
     ),
     'aggregator_categorize_items' => array(
       'arguments' => array('form' => NULL),
-      'file' => 'aggregator.pages.inc',
     ),
     'aggregator_feed_source' => array(
       'arguments' => array('feed' => NULL),
-      'file' => 'aggregator.pages.inc',
       'template' => 'aggregator-feed-source',
     ),
     'aggregator_block_item' => array(
@@ -53,26 +50,21 @@ function aggregator_theme() {
     ),
     'aggregator_summary_items' => array(
       'arguments' => array('summary_items' => NULL, 'source' => NULL),
-      'file' => 'aggregator.pages.inc',
       'template' => 'aggregator-summary-items',
     ),
     'aggregator_summary_item' => array(
       'arguments' => array('item' => NULL),
-      'file' => 'aggregator.pages.inc',
       'template' => 'aggregator-summary-item',
     ),
     'aggregator_item' => array(
       'arguments' => array('item' => NULL),
-      'file' => 'aggregator.pages.inc',
       'template' => 'aggregator-item',
     ),
     'aggregator_page_opml' => array(
       'arguments' => array('feeds' => NULL),
-      'file' => 'aggregator.pages.inc',
     ),
     'aggregator_page_rss' => array(
       'arguments' => array('feeds' => NULL, 'category' => NULL),
-      'file' => 'aggregator.pages.inc',
     ),
   );
 }
Index: modules/block/block.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/block/block.module,v
retrieving revision 1.334
diff -u -p -r1.334 block.module
--- modules/block/block.module	21 May 2009 23:07:14 -0000	1.334
+++ modules/block/block.module	22 May 2009 04:46:35 -0000
@@ -98,7 +98,6 @@ function block_theme() {
     ),  
     'block_admin_display_form' => array(
       'template' => 'block-admin-display-form',
-      'file' => 'block.admin.inc',
       'arguments' => array('form' => NULL),
     ),
   );
Index: modules/filter/filter.info
===================================================================
RCS file: /cvs/drupal/drupal/modules/filter/filter.info,v
retrieving revision 1.11
diff -u -p -r1.11 filter.info
--- modules/filter/filter.info	12 Oct 2008 01:23:03 -0000	1.11
+++ modules/filter/filter.info	24 May 2009 02:13:14 -0000
@@ -9,3 +9,4 @@ files[] = filter.admin.inc
 files[] = filter.pages.inc
 files[] = filter.install
 required = TRUE
+maintenance = TRUE
Index: modules/filter/filter.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/filter/filter.module,v
retrieving revision 1.251
diff -u -p -r1.251 filter.module
--- modules/filter/filter.module	21 May 2009 23:07:15 -0000	1.251
+++ modules/filter/filter.module	22 May 2009 04:46:35 -0000
@@ -47,15 +47,12 @@ function filter_theme() {
   return array(
     'filter_admin_overview' => array(
       'arguments' => array('form' => NULL),
-      'file' => 'filter.admin.inc',
     ),
     'filter_admin_order' => array(
       'arguments' => array('form' => NULL),
-      'file' => 'filter.admin.inc',
     ),
     'filter_tips' => array(
       'arguments' => array('tips' => NULL, 'long' => FALSE),
-      'file' => 'filter.pages.inc',
     ),
     'filter_tips_more_info' => array(
       'arguments' => array(),
Index: modules/menu/menu.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/menu/menu.module,v
retrieving revision 1.189
diff -u -p -r1.189 menu.module
--- modules/menu/menu.module	21 May 2009 23:07:15 -0000	1.189
+++ modules/menu/menu.module	22 May 2009 04:46:35 -0000
@@ -142,11 +142,9 @@ function menu_menu() {
 function menu_theme() {
   return array(
     'menu_overview_form' => array(
-      'file' => 'menu.admin.inc',
       'arguments' => array('form' => NULL),
     ),
     'menu_admin_overview' => array(
-      'file' => 'menu.admin.inc',
       'arguments' => array('title' => NULL, 'name' => NULL, 'description' => NULL),
     ),
   );
Index: modules/node/node.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/node/node.module,v
retrieving revision 1.1054
diff -u -p -r1.1054 node.module
--- modules/node/node.module	22 May 2009 11:34:05 -0000	1.1054
+++ modules/node/node.module	24 May 2009 01:49:19 -0000
@@ -105,27 +105,21 @@ function node_theme() {
     ),
     'node_filter_form' => array(
       'arguments' => array('form' => NULL),
-      'file' => 'node.admin.inc',
     ),
     'node_filters' => array(
       'arguments' => array('form' => NULL),
-      'file' => 'node.admin.inc',
     ),
     'node_admin_nodes' => array(
       'arguments' => array('form' => NULL),
-      'file' => 'node.admin.inc',
     ),
     'node_add_list' => array(
       'arguments' => array('content' => NULL),
-      'file' => 'node.pages.inc',
     ),
     'node_form' => array(
       'arguments' => array('form' => NULL),
-      'file' => 'node.pages.inc',
     ),
     'node_preview' => array(
       'arguments' => array('node' => NULL),
-      'file' => 'node.pages.inc',
     ),
     'node_log_message' => array(
       'arguments' => array('log' => NULL),
Index: modules/profile/profile.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/profile/profile.module,v
retrieving revision 1.255
diff -u -p -r1.255 profile.module
--- modules/profile/profile.module	21 May 2009 23:07:15 -0000	1.255
+++ modules/profile/profile.module	22 May 2009 04:46:35 -0000
@@ -67,7 +67,6 @@ function profile_theme() {
     ),
     'profile_admin_overview' => array(
       'arguments' => array('form' => NULL),
-      'file' => 'profile.admin.inc',
     )
   );
 }
Index: modules/search/search.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/search/search.module,v
retrieving revision 1.294
diff -u -p -r1.294 search.module
--- modules/search/search.module	22 May 2009 11:37:07 -0000	1.294
+++ modules/search/search.module	24 May 2009 01:49:19 -0000
@@ -126,12 +126,10 @@ function search_theme() {
     ),
     'search_result' => array(
       'arguments' => array('result' => NULL, 'type' => NULL),
-      'file' => 'search.pages.inc',
       'template' => 'search-result',
     ),
     'search_results' => array(
       'arguments' => array('results' => NULL, 'type' => NULL),
-      'file' => 'search.pages.inc',
       'template' => 'search-results',
     ),
     'search_results_listing' => array(
Index: modules/simpletest/simpletest.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/simpletest/simpletest.module,v
retrieving revision 1.45
diff -u -p -r1.45 simpletest.module
--- modules/simpletest/simpletest.module	21 May 2009 23:07:16 -0000	1.45
+++ modules/simpletest/simpletest.module	22 May 2009 04:46:35 -0000
@@ -70,11 +70,9 @@ function simpletest_theme() {
   return array(
     'simpletest_test_table' => array(
       'arguments' => array('table' => NULL),
-      'file' => 'simpletest.pages.inc',
     ),
     'simpletest_result_summary' => array(
       'arguments' => array('form' => NULL),
-      'file' => 'simpletest.pages.inc',
     ),
   );
 }
Index: modules/system/system.api.php
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.api.php,v
retrieving revision 1.37
diff -u -p -r1.37 system.api.php
--- modules/system/system.api.php	21 May 2009 23:07:16 -0000	1.37
+++ modules/system/system.api.php	22 May 2009 04:46:35 -0000
@@ -583,10 +583,6 @@ function hook_perm() {
  *   used as the default value if not specified to the theme() function.
  *   These arguments must be in the same order that they will be given to
  *   the theme() function.
- * - file: The file the implementation resides in. This file will be included
- *   prior to the theme being rendered, to make sure that the function or
- *   preprocess function (as needed) is actually loaded; this makes it possible
- *   to split theme functions out into separate files quite easily.
  * - path: Override the path of the file to be used. Ordinarily the module or
  *   theme path will be used, but if the file will not be in the default path,
  *   include it here. This path should be relative to the Drupal root
Index: modules/system/system.info
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.info,v
retrieving revision 1.12
diff -u -p -r1.12 system.info
--- modules/system/system.info	6 May 2009 10:37:28 -0000	1.12
+++ modules/system/system.info	24 May 2009 02:13:03 -0000
@@ -10,3 +10,4 @@ files[] = system.queue.inc
 files[] = image.gd.inc
 files[] = system.install
 required = TRUE
+maintenance = TRUE
Index: modules/system/system.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.module,v
retrieving revision 1.698
diff -u -p -r1.698 system.module
--- modules/system/system.module	22 May 2009 11:33:18 -0000	1.698
+++ modules/system/system.module	24 May 2009 01:49:19 -0000
@@ -121,43 +121,33 @@ function system_theme() {
   return array_merge(drupal_common_theme(), array(
     'system_theme_select_form' => array(
       'arguments' => array('form' => NULL),
-      'file' => 'system.admin.inc',
     ),
     'system_themes_form' => array(
       'arguments' => array('form' => NULL),
-      'file' => 'system.admin.inc',
     ),
     'system_modules_fieldset' => array(
       'arguments' => array('form' => NULL),
-      'file' => 'system.admin.inc',
     ),
     'system_modules_incompatible' => array(
       'arguments' => array('message' => NULL),
-      'file' => 'system.admin.inc',
     ),
     'system_modules_uninstall' => array(
       'arguments' => array('form' => NULL),
-      'file' => 'system.admin.inc',
     ),
     'status_report' => array(
       'arguments' => array('requirements' => NULL),
-      'file' => 'system.admin.inc',
     ),
     'admin_page' => array(
       'arguments' => array('blocks' => NULL),
-      'file' => 'system.admin.inc',
     ),
     'admin_block' => array(
       'arguments' => array('block' => NULL),
-      'file' => 'system.admin.inc',
     ),
     'admin_block_content' => array(
       'arguments' => array('content' => NULL),
-      'file' => 'system.admin.inc',
     ),
     'system_admin_by_module' => array(
       'arguments' => array('menu_items' => NULL),
-      'file' => 'system.admin.inc',
     ),
     'system_powered_by' => array(
       'arguments' => array('image_path' => NULL),
Index: modules/trigger/trigger.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/trigger/trigger.module,v
retrieving revision 1.34
diff -u -p -r1.34 trigger.module
--- modules/trigger/trigger.module	21 May 2009 23:07:16 -0000	1.34
+++ modules/trigger/trigger.module	22 May 2009 04:46:35 -0000
@@ -149,7 +149,6 @@ function trigger_theme() {
   return array(
     'trigger_display' => array(
       'arguments' => array('element'),
-      'file' => 'trigger.admin.inc',
     ),
   );
 }
Index: modules/user/user.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/user/user.module,v
retrieving revision 1.990
diff -u -p -r1.990 user.module
--- modules/user/user.module	22 May 2009 08:04:40 -0000	1.990
+++ modules/user/user.module	24 May 2009 01:49:20 -0000
@@ -42,40 +42,32 @@ function user_theme() {
     'user_profile' => array(
       'arguments' => array('elements' => NULL),
       'template' => 'user-profile',
-      'file' => 'user.pages.inc',
     ),
     'user_profile_category' => array(
       'arguments' => array('element' => NULL),
       'template' => 'user-profile-category',
-      'file' => 'user.pages.inc',
     ),
     'user_profile_item' => array(
       'arguments' => array('element' => NULL),
       'template' => 'user-profile-item',
-      'file' => 'user.pages.inc',
     ),
     'user_list' => array(
       'arguments' => array('users' => NULL, 'title' => NULL),
     ),
     'user_admin_perm' => array(
       'arguments' => array('form' => NULL),
-      'file' => 'user.admin.inc',
     ),
     'user_admin_new_role' => array(
       'arguments' => array('form' => NULL),
-      'file' => 'user.admin.inc',
     ),
     'user_admin_account' => array(
       'arguments' => array('form' => NULL),
-      'file' => 'user.admin.inc',
     ),
     'user_filter_form' => array(
       'arguments' => array('form' => NULL),
-      'file' => 'user.admin.inc',
     ),
     'user_filters' => array(
       'arguments' => array('form' => NULL),
-      'file' => 'user.admin.inc',
     ),
     'user_signature' => array(
       'arguments' => array('signature' => NULL),
