Index: includes/theme.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/theme.inc,v
retrieving revision 1.621
diff -u -p -r1.621 theme.inc
--- includes/theme.inc	28 Oct 2010 02:27:08 -0000	1.621
+++ includes/theme.inc	28 Oct 2010 22:56:27 -0000
@@ -363,7 +363,6 @@ function drupal_theme_rebuild() {
  */
 function _theme_process_registry(&$cache, $name, $type, $theme, $path) {
   $result = array();
-  $function = $name . '_theme';
 
   // Processor functions work in two distinct phases with the process
   // functions always being executed after the preprocess functions.
@@ -372,16 +371,36 @@ function _theme_process_registry(&$cache
     'process functions'    => 'process',
   );
 
+  // Invoke the hook_theme() implementation, process what is returned, and
+  // merge it into $cache.
+  $function = $name . '_theme';
   if (function_exists($function)) {
     $result = $function($cache, $type, $theme, $path);
     foreach ($result as $hook => $info) {
+      // A later hook_theme() implementation may return information for a theme
+      // hook that has already been declared by a prior hook_theme()
+      // implementation, and not re-specify values for every key. This enables a
+      // theme to override a module-provided default function or template,
+      // without having to duplicate all of the hook_theme() information defined
+      // by the module. Most of this function handles the special processing
+      // required to fill in all of the keys correctly. We start, however, by
+      // simply copying the ones that don't require any special processing.
+      if (isset($cache[$hook])) {
+        $keys = array('variables', 'render element', 'pattern', 'base hook');
+        $result[$hook] += array_intersect_key($cache[$hook], array_fill_keys($keys, TRUE));
+      }
+
+      // Fill in the type and path of the module, theme, or engine that
+      // implements this theme hook.
       $result[$hook]['type'] = $type;
       $result[$hook]['theme path'] = $path;
-      // if function and file are left out, default to standard naming
+
+      // If function and file are left out, default to standard naming
       // conventions.
       if (!isset($info['template']) && !isset($info['function'])) {
         $result[$hook]['function'] = ($type == 'module' ? 'theme_' : $name . '_') . $hook;
       }
+
       // If a path is set in the info, use what was set. Otherwise use the
       // default path. This is mostly so system.module can declare theme
       // functions on behalf of core .include files.
@@ -397,16 +416,6 @@ function _theme_process_registry(&$cache
         $result[$hook]['includes'][] = $include_file;
       }
 
-      // If these keys are left unspecified within overridden entries returned
-      // by hook_theme(), carry them forward from the prior entry. This is so
-      // that themes don't need to specify this information, since the module
-      // that registered the theme hook already has.
-      foreach (array('variables', 'render element', 'pattern', 'base hook') as $key) {
-        if (!isset($info[$key]) && isset($cache[$hook][$key])) {
-          $result[$hook][$key] = $cache[$hook][$key];
-        }
-      }
-
       // The following apply only to theming hooks implemented as templates.
       if (isset($info['template'])) {
         // Prepend the current theming path when none is set.
