From 6d5a3f211816ade612af40fbd34468be3b129ea9 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Fri, 15 Aug 2014 18:26:38 +0100 Subject: [PATCH] CRM-15128 - Prevent merging contact into self --- CRM/Contact/Form/Merge.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CRM/Contact/Form/Merge.php b/CRM/Contact/Form/Merge.php index f87eeeb22c..170727e74d 100644 --- a/CRM/Contact/Form/Merge.php +++ b/CRM/Contact/Form/Merge.php @@ -71,6 +71,11 @@ class CRM_Contact_Form_Merge extends CRM_Core_Form { $this->_gid = $gid = CRM_Utils_Request::retrieve('gid', 'Positive', $this, FALSE); $this->_mergeId = CRM_Utils_Request::retrieve('mergeId', 'Positive', $this, FALSE); + // Sanity check + if ($cid == $oid) { + CRM_Core_Error::statusBounce(ts('Cannot merge a contact with itself.')); + } + if (!CRM_Dedupe_BAO_Rule::validateContacts($cid, $oid)) { CRM_Core_Error::statusBounce(ts('The selected pair of contacts are marked as non duplicates. If these records should be merged, you can remove this exception on the Dedupe Exceptions page.', array(1 => CRM_Utils_System::url('civicrm/dedupe/exception', 'reset=1')))); } -- 2.25.1