Index: includes/theme.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/theme.inc,v
retrieving revision 1.415.2.19
diff -u -r1.415.2.19 theme.inc
--- includes/theme.inc	25 Feb 2009 21:02:16 -0000	1.415.2.19
+++ includes/theme.inc	23 Apr 2009 11:25:14 -0000
@@ -260,6 +260,7 @@
  * over how and when the preprocess functions are run.
  */
 function _theme_process_registry(&$cache, $name, $type, $theme, $path) {
+  static $default_preprocess_files = array();
   $result = array();
   $function = $name .'_theme';
   if (function_exists($function)) {
@@ -286,6 +287,15 @@
         include_once($info['path'] .'/'. $info['file']);
       }
 
+      // We need to make sure that module template preprocess hooks get included correctly
+      // when the theme file is overridden. This will only happen when 'file' is set.
+      if ($type == 'module' && isset($info['template']) && isset($info['file']) && function_exists('template_preprocess_'. $hook)) {
+        $default_preprocess_files[$hook] = (isset($info['path']) ? $info['path'] : $path) .'/'.  $info['file'];
+      }
+      elseif ($type != 'module' && isset($default_preprocess_files[$hook])) {
+        $result[$hook]['module_preprocess_file'] = $default_preprocess_files[$hook];
+      }
+
       if (isset($info['template']) && !isset($info['path'])) {
         $result[$hook]['template'] = $path .'/'. $info['template'];
       }
@@ -612,6 +622,9 @@
     }
     include_once($include_file);
   }
+  if (!empty($info['module_preprocess_file'])) {
+    include_once($info['module_preprocess_file']);
+  }
   if (isset($info['function'])) {
     // The theme call is a function.
     $output = call_user_func_array($info['function'], $args);
