Index: devel.module
===================================================================
RCS file: /cvs/drupal/contributions/modules/devel/devel.module,v
retrieving revision 1.184
diff -u -p -r1.184 devel.module
--- devel.module	13 Aug 2007 02:37:39 -0000	1.184
+++ devel.module	14 Aug 2007 18:50:12 -0000
@@ -759,6 +759,22 @@ function devel_cache_clear() {
     cache_clear_all('*', $table, TRUE);
   }
 
+  // This is definitely in the wrang spot.
+  if (variable_get('dev_template_log', 0)) {
+    init_theme(); // Doesn't fully initialize.
+    global $theme; // cannot get theme information. Being called too early?
+    $theme_registry = theme_get_registry();
+    foreach ($theme_registry as $hook => $data) {
+      // Add in devel_preprocess so it's used as the last variable preprocessor.
+      // This way, it can gather *all* template suggestions, not just the ones set by modules.
+      if (isset($data['file']) && !in_array('devel_preprocess', $data['preprocess functions'])) {
+        $theme_registry[$hook]['preprocess functions'][] = 'devel_preprocess';
+      }
+    }
+    //_theme_save_registry('garland', $theme_registry); // Can't get this to work due to init_theme().
+    cache_set("theme_registry:garland", $theme_registry); // Hard coded just to test.
+  }
+
   drupal_clear_css_cache();
   menu_rebuild();
 
@@ -900,15 +916,17 @@ function devel_get_theme_extension() {
  * for all template calls. Core seems not to allow logging of theme *functions*, just templates. Help!
  *
  * If you use an engine other than phptemplate, just define ENGINE_preprocess() function using same code as this function.
-*/
-function phptemplate_preprocess($vars, $function) {
+ * 
+ * Changed from phptemplate_preprocess. phptemplate_* should be reserved for themes and engines.
+ * @see devel_cache_clear() it injects this preprocessor.
+ */
+function devel_preprocess($vars, $function) {
   $GLOBALS['devel_theme_functions'][] = array(
     'function' => $function,
     'template_files' => $vars['template_files']
   );
 }
 
-
 // menu callback
 function devel_theme_registry() {
   init_theme();
