From 22f453ce3d1b3a0282ea55561f33d421e5e6f317 Mon Sep 17 00:00:00 2001 From: Justin Freeman Date: Wed, 2 Feb 2022 16:52:52 +1100 Subject: [PATCH] CIVICRM-1922 CIVICRM-552 CIVICRM-906 Merging an Organisation contact and de-selecting the merge Membership checkbox causes all related Membership to not be removed and the Primary Membership is linked to the deleted Organisation --- CRM/Contact/Form/Merge.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CRM/Contact/Form/Merge.php b/CRM/Contact/Form/Merge.php index 45fff4c56b..42bf682e86 100644 --- a/CRM/Contact/Form/Merge.php +++ b/CRM/Contact/Form/Merge.php @@ -313,7 +313,17 @@ class CRM_Contact_Form_Merge extends CRM_Core_Form { $formValues['main_details'] = $this->_mainDetails; $formValues['other_details'] = $this->_otherDetails; + + // Check if any rel_tables checkboxes have been de-selected + $rowsElementsAndInfo = CRM_Dedupe_Merger::getRowsElementsAndInfo($this->_cid, $this->_oid); + // If rel_tables is not set then initialise with 0 value, required for the check which calls removeContactBelongings in moveAllBelongings + foreach (array_keys($rowsElementsAndInfo['rel_tables']) as $relTableElement) { + if (!array_key_exists($relTableElement, $formValues)) { + $formValues[$relTableElement] = '0'; + } + } $migrationData = ['migration_info' => $formValues]; + CRM_Utils_Hook::merge('form', $migrationData, $this->_cid, $this->_oid); CRM_Dedupe_Merger::moveAllBelongings($this->_cid, $this->_oid, $migrationData['migration_info']); -- 2.25.1