diff --git a/core/includes/module.inc b/core/includes/module.inc
index ef09b57..ed73f9a 100644
--- a/core/includes/module.inc
+++ b/core/includes/module.inc
@@ -948,14 +948,14 @@ function module_implements_write_cache() {
 /**
  * Invokes a hook in a particular module.
  *
- * @param $module
+ * @param text $module
  *   The name of the module (without the .module extension).
- * @param $hook
+ * @param text $hook
  *   The name of the hook to invoke.
  * @param ...
  *   Arguments to pass to the hook implementation.
  *
- * @return
+ * @return any
  *   The return value of the hook implementation.
  */
 function module_invoke($module, $hook) {
@@ -963,19 +963,23 @@ function module_invoke($module, $hook) {
   // Remove $module and $hook from the arguments.
   unset($args[0], $args[1]);
   if (module_hook($module, $hook)) {
-    return call_user_func_array($module . '_' . $hook, $args);
+    $function = $module . '_' . $hook;
+    // Is this a valid function to run?
+    if (module_function_user_defined($function)) {
+      return call_user_func_array($function, $args);
+    }
   }
 }
 
 /**
  * Invokes a hook in all enabled modules that implement it.
  *
- * @param $hook
+ * @param text $hook
  *   The name of the hook to invoke.
  * @param ...
  *   Arguments to pass to the hook.
  *
- * @return
+ * @return array
  *   An array of return values of the hook implementations. If modules return
  *   arrays from their implementations, those are merged into one array.
  */
@@ -986,7 +990,16 @@ function module_invoke_all($hook) {
   $return = array();
   foreach (module_implements($hook) as $module) {
     $function = $module . '_' . $hook;
+    // Does this module define that hook?
     if (function_exists($function)) {
+      // Maybe, ensure this is user defined.
+      if (!module_function_user_defined($function)) {
+        // Not a user defined function? Skip it.
+        continue;
+      }
+
+      // To reach this step either the function exists and is user defined
+      // or PHP is not returning function names appropriately.
       $result = call_user_func_array($function, $args);
       if (isset($result) && is_array($result)) {
         $return = array_merge_recursive($return, $result);
@@ -1001,6 +1014,32 @@ function module_invoke_all($hook) {
 }
 
 /**
+ * Tests if the given function is user defined or not.
+ *
+ * @param text $function
+ *   The name of the function
+ *
+ * @return boolean
+ *   If the function exists and is user defined.
+ */
+function module_function_user_defined($function) {
+  // This can't be cached as new files may be included at any time.
+  $defined = get_defined_functions();
+  // Tests if PHP knows of user functions. Can safely assume there are.
+  if (!isset($defined['user'])) {
+    // Unable to test, return success so it can potentially fail elsewhere.
+    // Returning 1 instead of TRUE so a type equals can be applied.
+    return 1;
+  }
+  if (in_array($function, $defined['user'])) {
+    // This is a user defined function, yay!
+    return TRUE;
+  }
+  // This function is not listed as user defined.
+  return FALSE;
+}
+
+/**
  * @} End of "defgroup hooks".
  */
 
