Index: includes/theme.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/theme.inc,v retrieving revision 1.622 diff -u -p -b -r1.622 theme.inc --- includes/theme.inc 30 Oct 2010 03:57:20 -0000 1.622 +++ includes/theme.inc 16 Nov 2010 03:36:40 -0000 @@ -823,19 +823,30 @@ function theme($hook, $variables = array // Invoke the variable processors, if any. The processors may specify // alternate suggestions for which hook's template/function to use. If the // hook is a suggestion of a base hook, invoke the variable processors of - // the base hook, but retain the suggestion as a high priority suggestion to - // be used unless overridden by a variable processor function. + // the base hook. + $variables['theme_hook_suggestions'] = array(); if (isset($info['base hook'])) { $base_hook = $info['base hook']; $base_hook_info = $hooks[$base_hook]; + if (isset($base_hook_info['preprocess functions']) || isset($base_hook_info['process functions'])) { $variables['theme_hook_suggestion'] = $hook; - $hook = $base_hook; - $info = $base_hook_info; + foreach (array('preprocess functions', 'process functions') as $phase) { + if (!empty($base_hook_info[$phase])) { + foreach ($base_hook_info[$phase] as $processor_function) { + if (function_exists($processor_function)) { + // We don't want a poorly behaved process function changing $hook. + $hook_clone = $base_hook; + $processor_function($variables, $hook_clone); + } + } } } + } + } + + // Run any preprocess and process functions belonging to this hook. if (isset($info['preprocess functions']) || isset($info['process functions'])) { - $variables['theme_hook_suggestions'] = array(); foreach (array('preprocess functions', 'process functions') as $phase) { if (!empty($info[$phase])) { foreach ($info[$phase] as $processor_function) { @@ -847,6 +858,8 @@ function theme($hook, $variables = array } } } + } + // If the preprocess/process functions specified hook suggestions, and the // suggestion exists in the theme registry, use it instead of the hook that // theme() was called with. This allows the preprocess/process step to @@ -872,7 +885,6 @@ function theme($hook, $variables = array break; } } - } // Generate the output using either a function or a template. $output = '';