CRM-18480: Don't allow 'deleted' contacts to be merged
authorJKingsnorth <john@johnkingsnorth.co.uk>
Thu, 28 Apr 2016 15:07:18 +0000 (16:07 +0100)
committerJKingsnorth <john@johnkingsnorth.co.uk>
Thu, 28 Apr 2016 15:07:18 +0000 (16:07 +0100)
CRM/Dedupe/Merger.php

index a983913124dc388598fb8e0436ec89481f2ff963..eec229b6afb78e8cb394bfbbb5e3060ca6023783 100644 (file)
@@ -993,6 +993,12 @@ INNER JOIN  civicrm_membership membership2 ON membership1.membership_type_id = m
       if (empty($result['values'][$cid]['contact_type'])) {
         return FALSE;
       }
+
+      // CRM-18480: Cancel the process if the contact is already deleted
+      if (isset($result['values'][$cid]['contact_is_deleted']) && !empty($result['values'][$cid]['contact_is_deleted'])) {
+        CRM_Core_Error::fatal(ts('Cannot merge because the \'%1\' contact (ID %2) has been deleted.', array(1 => $moniker, 2 => $cid)));
+      }
+
       $$moniker = $result['values'][$cid];
     }
 
@@ -1834,7 +1840,6 @@ INNER JOIN  civicrm_membership membership2 ON membership1.membership_type_id = m
     $contactFields = CRM_Contact_DAO_Contact::fields();
     $invalidFields = array(
       'api_key',
-      'contact_is_deleted',
       'created_date',
       'display_name',
       'hash',