Index: includes/common.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/common.inc,v
retrieving revision 1.678
diff -u -p -r1.678 common.inc
--- includes/common.inc	23 Aug 2007 16:41:19 -0000	1.678
+++ includes/common.inc	24 Aug 2007 15:55:28 -0000
@@ -2624,7 +2624,7 @@ function drupal_common_themes() {
     ),
     'page' => array(
       'arguments' => array('content' => NULL, 'show_blocks' => TRUE, 'show_messages' => TRUE),
-      'file' => 'page',
+      'template' => 'page',
     ),
     'maintenance_page' => array(
       'arguments' => array('content' => NULL, 'show_messages' => TRUE),
@@ -2664,11 +2664,11 @@ function drupal_common_themes() {
     ),
     'box' => array(
       'arguments' => array('title' => NULL, 'content' => NULL, 'region' => 'main'),
-      'file' => 'box',
+      'template' => 'box',
     ),
     'block' => array(
       'arguments' => array('block' => NULL),
-      'file' => 'block',
+      'template' => 'block',
     ),
     'mark' => array(
       'arguments' => array('type' => MARK_NEW),
Index: includes/theme.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/theme.inc,v
retrieving revision 1.370
diff -u -p -r1.370 theme.inc
--- includes/theme.inc	23 Aug 2007 16:41:19 -0000	1.370
+++ includes/theme.inc	24 Aug 2007 15:55:29 -0000
@@ -231,14 +231,24 @@ function _theme_process_registry(&$cache
       $result[$hook]['theme path'] = $path;
       // if function and file are left out, default to standard naming
       // conventions.
-      if (!isset($info['file']) && !isset($info['function'])) {
+      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($result[$hook]['file']);
+      }
+      elseif (isset($info['file']) && isset($info['path'])) {
+        include_once($info['path'] .'/'. $info['file']);
+      }
+      
+      if (isset($info['template']) && !isset($info['path'])) {
+        $result[$hook]['template'] = $path .'/'. $info['template'];
       }
       // If 'arguments' have been defined previously, carry them forward.
       // This should happen if a theme overrides a Drupal defined theme
@@ -492,16 +502,16 @@ function theme() {
   // point path_to_theme() to the currently used theme path:
   $theme_path = $hooks[$hook]['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($include_file);
+  }
   if (isset($info['function'])) {
     // The theme call is a function.
-    // Include a file if this theme function is held elsewhere.
-    if (!empty($info['file'])) {
-      $function_file = $info['file'];
-      if (isset($info['path'])) {
-        $function_file = $info['path'] .'/'. $function_file;
-      }
-      include_once($function_file);
-    }
     $output = call_user_func_array($info['function'], $args);
   }
   else {
@@ -566,7 +576,7 @@ function theme() {
     }
 
     if (empty($template_file)) {
-      $template_file = $hooks[$hook]['file'] . $extension;
+      $template_file = $hooks[$hook]['template'] . $extension;
       if (isset($hooks[$hook]['path'])) {
         $template_file = $hooks[$hook]['path'] .'/'. $template_file;
       }
@@ -678,7 +688,7 @@ function drupal_find_theme_templates($ca
     $hook = strtr($template, '-', '_');
     if (isset($cache[$hook])) {
       $templates[$hook] = array(
-        'file' => $template,
+        'template' => $template,
         'path' => dirname($file->filename),
       );
     }
@@ -698,7 +708,7 @@ function drupal_find_theme_templates($ca
           $file = substr($match, 0, strpos($match, '.'));
           // Put the underscores back in for the hook name and register this pattern.
           $templates[strtr($file, '-', '_')] = array(
-            'file' => $file,
+            'template' => $file,
             'path' => dirname($files[$match]->filename),
             'arguments' => $info['arguments'],
           );
Index: modules/block/block.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/block/block.module,v
retrieving revision 1.275
diff -u -p -r1.275 block.module
--- modules/block/block.module	19 Aug 2007 08:08:44 -0000	1.275
+++ modules/block/block.module	24 Aug 2007 15:55:29 -0000
@@ -103,7 +103,7 @@ function block_help($path, $arg) {
 function block_theme() {
   return array(
     'block_admin_display' => array(
-      'file' => 'block-admin-display',
+      'template' => 'block-admin-display',
       'arguments' => array('form' => NULL),
     ),
   );
Index: modules/comment/comment.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/comment/comment.module,v
retrieving revision 1.573
diff -u -p -r1.573 comment.module
--- modules/comment/comment.module	12 Aug 2007 16:12:00 -0000	1.573
+++ modules/comment/comment.module	24 Aug 2007 15:55:30 -0000
@@ -160,11 +160,11 @@ function comment_theme() {
       'arguments' => array('form' => NULL),
     ),
     'comment' => array(
-      'file' => 'comment.tpl.php',
+      'template' => 'comment',
       'arguments' => array('comment' => NULL, 'node' => NULL, 'links' => array()),
     ),
     'comment_folded' => array(
-      'file' => 'comment-folded',
+      'template' => 'comment-folded',
       'arguments' => array('comment' => NULL),
     ),
     'comment_flat_collapsed' => array(
@@ -183,7 +183,7 @@ function comment_theme() {
       'arguments' => array('nid' => NULL),
     ),
     'comment_wrapper' => array(
-      'file' => 'comment-wrapper',
+      'template' => 'comment-wrapper',
       'arguments' => array('content' => NULL, 'node' => NULL),
     ),
     'comment_submitted' => array(
Index: modules/forum/forum.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/forum/forum.module,v
retrieving revision 1.413
diff -u -p -r1.413 forum.module
--- modules/forum/forum.module	12 Aug 2007 15:55:36 -0000	1.413
+++ modules/forum/forum.module	24 Aug 2007 15:55:31 -0000
@@ -34,27 +34,27 @@ function forum_help($path, $arg) {
 function forum_theme() {
   return array(
     'forums' => array(
-      'file' => 'forums',
+      'template' => 'forums',
       'arguments' => array('forums' => NULL, 'topics' => NULL, 'parents' => NULL, 'tid' => NULL, 'sortby' => NULL, 'forum_per_page' => NULL),
     ),
     'forum_list' => array(
-      'file' => 'forum-list',
+      'template' => 'forum-list',
       'arguments' => array('forums' => NULL, 'parents' => NULL, 'tid' => NULL),
     ),
     'forum_topic_list' => array(
-      'file' => 'forum-topic-list',
+      'template' => 'forum-topic-list',
       'arguments' => array('tid' => NULL, 'topics' => NULL, 'sortby' => NULL, 'forum_per_page' => NULL),
     ),
     'forum_icon' => array(
-      'file' => 'forum-icon',
+      'template' => 'forum-icon',
       'arguments' => array('new_posts' => NULL, 'num_posts' => 0, 'comment_mode' => 0, 'sticky' => 0),
     ),
     'forum_topic_navigation' => array(
-      'file' => 'forum-topic-navigation',
+      'template' => 'forum-topic-navigation',
       'arguments' => array('node' => NULL),
     ),
     'forum_submitted' => array(
-      'file' => 'forum-submitted',
+      'template' => 'forum-submitted',
       'arguments' => array('topic' => NULL),
     ),
   );
Index: modules/node/node.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/node/node.module,v
retrieving revision 1.872
diff -u -p -r1.872 node.module
--- modules/node/node.module	20 Aug 2007 07:03:08 -0000	1.872
+++ modules/node/node.module	24 Aug 2007 15:55:32 -0000
@@ -63,7 +63,7 @@ function node_theme() {
   return array(
     'node' => array(
       'arguments' => array('node' => NULL, 'teaser' => FALSE, 'page' => FALSE),
-      'file' => 'node',
+      'template' => 'node',
     ),
     'node_list' => array(
       'arguments' => array('items' => NULL, 'title' => NULL),
@@ -74,32 +74,26 @@ function node_theme() {
     'node_filter_form' => array(
       'arguments' => array('form' => NULL),
       'file' => 'node.admin.inc',
-      'function' => 'theme_node_filter_form',
     ),
     'node_filters' => array(
       'arguments' => array('form' => NULL),
       'file' => 'node.admin.inc',
-      'function' => 'theme_node_filters',
     ),
     'node_admin_nodes' => array(
       'arguments' => array('form' => NULL),
       'file' => 'node.admin.inc',
-      'function' => 'theme_node_admin_nodes',
     ),
     'node_add_list' => array(
       'arguments' => array('content' => NULL),
       'file' => 'node.pages.inc',
-      'function' => 'theme_node_add_list',
     ),
     'node_form' => array(
       'arguments' => array('form' => NULL),
       'file' => 'node.pages.inc',
-      'function' => 'theme_node_form',
     ),
     'node_preview' => array(
       'arguments' => array('node' => NULL),
       'file' => 'node.pages.inc',
-      'function' => 'theme_node_preview',
     ),
     'node_log_message' => array(
       'arguments' => array('log' => NULL),
Index: modules/poll/poll.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/poll/poll.module,v
retrieving revision 1.237
diff -u -p -r1.237 poll.module
--- modules/poll/poll.module	9 Aug 2007 10:37:41 -0000	1.237
+++ modules/poll/poll.module	24 Aug 2007 15:55:32 -0000
@@ -33,15 +33,15 @@ function poll_init() {
 function poll_theme() {
   return array(
     'poll_vote' => array(
-      'file' => 'poll-vote',
+      'template' => 'poll-vote',
       'arguments' => array('form' => NULL),
     ),
     'poll_results' => array(
-      'file' => 'poll-results',
+      'template' => 'poll-results',
       'arguments' => array('raw_title' => NULL, 'results' => NULL, 'votes' => NULL, 'raw_links' => NULL, 'block' => NULL, 'nid' => NULL, 'vote' => NULL),
     ),
     'poll_bar' => array(
-      'file' => 'poll-bar',
+      'template' => 'poll-bar',
       'arguments' => array('title' => NULL, 'votes' => NULL, 'total_votes' => NULL, 'vote' => NULL, 'block' => NULL),
     ),
   );
Index: modules/profile/profile.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/profile/profile.module,v
retrieving revision 1.216
diff -u -p -r1.216 profile.module
--- modules/profile/profile.module	19 Aug 2007 08:08:44 -0000	1.216
+++ modules/profile/profile.module	24 Aug 2007 15:55:33 -0000
@@ -58,15 +58,15 @@ function profile_theme() {
   return array(
     'profile_block' => array(
       'arguments' => array('account' => NULL, 'fields' => array()),
-      'file' => 'profile-block',
+      'template' => 'profile-block',
     ),
     'profile_listing' => array(
       'arguments' => array('account' => NULL, 'fields' => array()),
-      'file' => 'profile-listing',
+      'template' => 'profile-listing',
     ),
     'profile_wrapper' => array(
       'arguments' => array('content' => NULL),
-      'file' => 'profile-wrapper',
+      'template' => 'profile-wrapper',
     )
   );
 }
Index: modules/user/user.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/user/user.module,v
retrieving revision 1.834
diff -u -p -r1.834 user.module
--- modules/user/user.module	19 Aug 2007 08:08:45 -0000	1.834
+++ modules/user/user.module	24 Aug 2007 15:55:35 -0000
@@ -31,19 +31,19 @@ function user_theme() {
   return array(
     'user_picture' => array(
       'arguments' => array('account' => NULL),
-      'file' => 'user-picture',
+      'template' => 'user-picture',
     ),
     'user_profile' => array(
       'arguments' => array('account' => NULL),
-      'file' => 'user-profile',
+      'template' => 'user-profile',
     ),
     'user_profile_category' => array(
       'arguments' => array('element' => NULL),
-      'file' => 'user-profile-category',
+      'template' => 'user-profile-category',
     ),
     'user_profile_item' => array(
       'arguments' => array('element' => NULL),
-      'file' => 'user-profile-item',
+      'template' => 'user-profile-item',
     ),
     'user_list' => array(
       'arguments' => array('users' => NULL, 'title' => NULL),
