From 2af22388da9fce6f1c1dad18268652b8944bdb10 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Dani=C3=ABl?= Date: Fri, 22 Sep 2017 13:19:52 +0200 Subject: [PATCH] CRM-21214 - Fix address sharing 1 --- CRM/Contact/BAO/Contact/Utils.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CRM/Contact/BAO/Contact/Utils.php b/CRM/Contact/BAO/Contact/Utils.php index 024ef85042..2e070cd1b4 100644 --- a/CRM/Contact/BAO/Contact/Utils.php +++ b/CRM/Contact/BAO/Contact/Utils.php @@ -832,6 +832,14 @@ INNER JOIN civicrm_contact contact_target ON ( contact_target.id = act.contact_i $masterAddress->id = CRM_Utils_Array::value('master_id', $values); $masterAddress->find(TRUE); + //if address master address is shared, use its master (prevent chaining) + if ($masterAddress->master_id > 0) { + $values['master_id'] = $masterAddress->master_id; + $masterAddress = new CRM_Core_BAO_Address(); + $masterAddress->id = CRM_Utils_Array::value('master_id', $values); + $masterAddress->find(TRUE); + } + // 4. modify submitted params and update it with shared contact address // make sure you preserve specific form values like location type, is_primary_ is_billing, master_id // CRM-10336: Also empty any fields from the existing address block if they don't exist in master (otherwise they will persist) -- 2.25.1