=== modified file 'includes/theme.inc'
--- includes/theme.inc	2007-09-17 11:11:57 +0000
+++ includes/theme.inc	2007-09-21 08:54:58 +0000
@@ -273,21 +273,17 @@ function _theme_process_registry(&$cache
       if (!isset($info['preprocess functions']) || !is_array($info['preprocess functions'])) {
         $info['preprocess functions'] = array();
         $prefix = ($type == 'module' ? 'template' : $name);
-        // theme engines get an extra set that come before the normally named preprocess.
-        if ($type == 'theme_engine') {
-          if (function_exists($prefix .'_engine_preprocess')) {
-            $info['preprocess functions'][] = $prefix .'_engine_preprocess';
-          }
-          if (function_exists($prefix .'_engine_preprocess_'. $hook)) {
-            $info['preprocess functions'][] = $prefix .'_engine_preprocess_'. $hook;
-          }
-        }
-
-        // Let the theme engine register theme specific variable functions.
         $prefixes = array($prefix);
         if ($type == 'theme_engine') {
+        // theme engines get an extra set that come before the normally named preprocess.
+          array_unshift($prefixes, $prefix .'_engine');
           $prefixes[] = $theme;
+          // Also let modules intervene, we put this into the theme_engine to make sure it fires only once.
+          foreach (module_list() as $module) {
+            $prefixes[] = 'template_'. $module;
+          }
         }
+
         foreach ($prefixes as $prefix) {
           if (function_exists($prefix .'_preprocess')) {
             $info['preprocess functions'][] = $prefix .'_preprocess';
@@ -462,6 +458,10 @@ function list_theme_engines($refresh = F
  *   their functions so that they may share code. In PHPTemplate, these
  *   functions will appear in template.php
  *
+ * template_MODULENAME_preprocess_hook(&$variables)
+ *   This is meant to be used by modules that want to provides some extra
+ *   variables for an existing theme hook.
+ *
  * THEME_preprocess_HOOK(&$variables)
  *
  * THEME_preprocess(&$variables)

