Index: includes/theme.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/theme.inc,v
retrieving revision 1.385
diff -u -p -r1.385 theme.inc
--- includes/theme.inc	25 Sep 2007 12:43:18 -0000	1.385
+++ includes/theme.inc	3 Oct 2007 01:33:15 -0000
@@ -273,21 +273,19 @@ 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;
         }
+
+        if ($type == 'module') {
+          // Also let modules intervene
+          $prefixes += module_list();
+        }
+
         foreach ($prefixes as $prefix) {
           if (function_exists($prefix .'_preprocess')) {
             $info['preprocess functions'][] = $prefix .'_preprocess';
@@ -446,37 +444,41 @@ function list_theme_engines($refresh = F
  * applicable) and the theme. The following functions may be used to modify
  * the $variables array:
  *
- * ENGINE_engine_preprocess(&$variables)
+ * - ENGINE_engine_preprocess(&$variables)
  *   This function should only be implemented by theme engines and exists
  *   so that the theme engine can set necessary variables. It is commonly
  *   used to set global variables such as $directory and $is_front_page.
  *
- * ENGINE_engine_preprocess_HOOK(&$variables)
+ * - ENGINE_engine_preprocess_HOOK(&$variables)
  *   This is the same as the previous function, but is called only per hook.
  *
- * ENGINE_preprocess_HOOK(&$variables)
+ * - ENGINE_preprocess_HOOK(&$variables)
  *
- * ENGINE_preprocess(&$variables)
+ * - ENGINE_preprocess(&$variables)
  *   This is meant to be used by themes that utilize a theme engine; as it is
  *   good practice for these themes to use the theme engine's name for
  *   their functions so that they may share code. In PHPTemplate, these
  *   functions will appear in template.php
  *
- * THEME_preprocess_HOOK(&$variables)
+ * - THEME_preprocess_HOOK(&$variables)
  *
- * THEME_preprocess(&$variables)
+ * - THEME_preprocess(&$variables)
  *   These functions are based upon the raw theme; they should primarily be
  *   used by themes that do not use an engine or by themes that need small
  *   changes to what has already been established in the theme engine version
  *   of the function.
  *
- * template_preprocess(&$variables)
- *   This function will only be called for theme functions registered by
- *   the named module. In general it is preferred to use the following
- *   function if possible, but it may not always be the case.
- *
- * template_preprocess_HOOK(&$variables)
- *   This is the same as the previous function, but is called only per hook.
+ * - template_preprocess_HOOK(&$variables)
+ *   This is called for the hook; it should be implemented by the module that
+ *   registers the hook, and will always be called if the hook is a template.
+ *
+ * - MODULE_preprocess(&$variables)
+ *   This will be called for all templates; it should only be used if there
+ *   is a really good reason.
+ *
+ * - MODULE_preprocess_hook(&$variables)
+ *   This is meant to be used by modules that want to provides some extra
+ *   variables for an existing theme hook.
  *
  * There are two special variables that these hooks can set:
  *   'template_file' and 'template_files'. These will be merged together
