diff --git a/core/includes/form.inc b/core/includes/form.inc
index c94bc62..292926e 100644
--- a/core/includes/form.inc
+++ b/core/includes/form.inc
@@ -1043,29 +1043,33 @@ function drupal_prepare_form($form_id, &$form, &$form_state) {
   if (!isset($form['#validate'])) {
     // Ensure that modules can rely on #validate being set.
     $form['#validate'] = array();
-    // Check for a handler specific to $form_id.
-    if (function_exists($form_id . '_validate')) {
+  }
+  // Check for a handler specific to $form_id.
+  if (function_exists($form_id . '_validate')) {
+    if (!in_array($form_id . '_validate', $form['#validate'])) {
       $form['#validate'][] = $form_id . '_validate';
     }
-    // Otherwise check whether this is a shared form and whether there is a
-    // handler for the shared $form_id.
-    elseif (isset($form_state['build_info']['base_form_id']) && function_exists($form_state['build_info']['base_form_id'] . '_validate')) {
-      $form['#validate'][] = $form_state['build_info']['base_form_id'] . '_validate';
-    }
+  }
+  // Otherwise check whether this is a shared form and whether there is a
+  // handler for the shared $form_id.
+  elseif (isset($form_state['build_info']['base_form_id']) && function_exists($form_state['build_info']['base_form_id'] . '_validate')) {
+    $form['#validate'][] = $form_state['build_info']['base_form_id'] . '_validate';
   }
 
   if (!isset($form['#submit'])) {
     // Ensure that modules can rely on #submit being set.
     $form['#submit'] = array();
-    // Check for a handler specific to $form_id.
-    if (function_exists($form_id . '_submit')) {
+  }
+  // Check for a handler specific to $form_id.
+  if (function_exists($form_id . '_submit')) {
+    if (!in_array($form_id . '_submit', $form['#submit'])) {
       $form['#submit'][] = $form_id . '_submit';
     }
-    // Otherwise check whether this is a shared form and whether there is a
-    // handler for the shared $form_id.
-    elseif (isset($form_state['build_info']['base_form_id']) && function_exists($form_state['build_info']['base_form_id'] . '_submit')) {
-      $form['#submit'][] = $form_state['build_info']['base_form_id'] . '_submit';
-    }
+  }
+  // Otherwise check whether this is a shared form and whether there is a
+  // handler for the shared $form_id.
+  elseif (isset($form_state['build_info']['base_form_id']) && function_exists($form_state['build_info']['base_form_id'] . '_submit')) {
+    $form['#submit'][] = $form_state['build_info']['base_form_id'] . '_submit';
   }
 
   // If no #theme has been set, automatically apply theme suggestions.
