diff --git a/includes/form.inc b/includes/form.inc
index 0839a90b16af2d605247a168df35886e2bd205c7..d0db80c9ff755ac1faa3fe56245d42ae7b4d8d28 100644
--- a/includes/form.inc
+++ b/includes/form.inc
@@ -103,10 +103,10 @@ function drupal_get_form($form_id, &$form, $callback = NULL) {
     }
   }
 
-  if (function_exists('theme_' . $form_id)) {
+  if (theme_get_function($form_id)) {
     $form['#theme'] = $form_id;
   }
-  elseif (function_exists('theme_' . $callback)) {
+  elseif (theme_get_function($callback)) {
     $form['#theme'] = $callback;
   }
   return form_render($form);
diff --git a/includes/theme.inc b/includes/theme.inc
index e025299e61ba5809d0269a0d31b8ed56b6fdac1f..13f2e6d480dc6bc61e7c3b47dd120dd2435b1421 100644
--- a/includes/theme.inc
+++ b/includes/theme.inc
@@ -159,6 +159,23 @@ function list_theme_engines($refresh = FALSE) {
  *   An HTML string that generates the themed output.
  */
 function theme() {
+  $args = func_get_args();
+  $function = array_shift($args);
+
+  if ($func = theme_get_function($function)) {
+    return call_user_func_array($func, $args);
+  }
+}
+
+/**
+ * Determine if a theme function exists, and if so return which one was found.
+ *
+ * @param $function
+ *   The name of the theme function to test.
+ * @return
+ *   The name of the theme function that should be used, or false if no function exists.
+ */
+function theme_get_function($function) {
   global $theme, $theme_engine;
 
   // Because theme() is called a lot, calling init_theme() only to have it
@@ -167,21 +184,19 @@ function theme() {
     init_theme();
   }
 
-  $args = func_get_args();
-  $function = array_shift($args);
-
   if (($theme != '') && function_exists($theme .'_'. $function)) {
     // call theme function
-    return call_user_func_array($theme .'_'. $function, $args);
+    return $theme .'_'. $function;
   }
   elseif (($theme != '') && isset($theme_engine) && function_exists($theme_engine .'_'. $function)) {
     // call engine function
-    return call_user_func_array($theme_engine .'_'. $function, $args);
+    return $theme_engine .'_'. $function;
   }
   elseif (function_exists('theme_'. $function)){
     // call Drupal function
-    return call_user_func_array('theme_'. $function, $args);
+    return 'theme_'. $function;
   }
+  return false;
 }
 
 /**