Index: includes/theme.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/theme.inc,v
retrieving revision 1.598
diff -u -p -r1.598 theme.inc
--- includes/theme.inc	19 May 2010 19:22:24 -0000	1.598
+++ includes/theme.inc	30 May 2010 21:33:59 -0000
@@ -866,6 +866,24 @@ function theme($hook, $variables = array
     if (function_exists($info['function'])) {
       $output = $info['function']($variables);
     }
+    else {
+      $default_function = 'theme_' . $hook;
+      // If the theme function is overridden, try to fall back on the default.
+      if ($info['function'] != $default_function && function_exists($default_function)) {
+        watchdog('theme', 'Theme function "@function" is registered, but not found. Falling back on default.', array('@function' => $info['function']), WATCHDOG_WARNING);
+        $output = $default_function($variables);
+      }
+      // Edge case: the default theme function does not exist.
+      else {
+        if ($info['function'] != $default_function) {
+          watchdog('theme', 'Theme functions "@override" and "@default" are not found.', array('@override' => $info['function'], '@default' => $default_function), WATCHDOG_ERROR);
+        }
+        else {
+          watchdog('theme', 'Theme function "@function" is not found.', array('@function' => $info['function']), WATCHDOG_ERROR);
+        }
+        $output = '';
+      }
+    }
   }
   else {
     // Default render function and extension.
