From 39d6826b670caebce0c0df6803f68dc8cbac0799 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Dani=C3=ABl?= <9696905+DanielvV@users.noreply.github.com> Date: Mon, 25 Sep 2017 15:59:14 +0200 Subject: [PATCH] CRM-21214 - Fix address sharing 2 - some more changes --- CRM/Core/BAO/Address.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/CRM/Core/BAO/Address.php b/CRM/Core/BAO/Address.php index 879785fc40..587430b98b 100644 --- a/CRM/Core/BAO/Address.php +++ b/CRM/Core/BAO/Address.php @@ -87,7 +87,8 @@ class CRM_Core_BAO_Address extends CRM_Core_DAO_Address { } } - if ($value['id'] == $value['master_id']) { + //this prevents an endless loop (prevent chaining) CRM-21214 + if (!empty($value['id']) && !empty($value['master_id']) && $value['id'] == $value['master_id']) { $value['master_id'] = 'null'; CRM_Core_Session::setStatus(ts("You can't connect an address to itself"), '', 'warning'); } @@ -179,8 +180,8 @@ class CRM_Core_BAO_Address extends CRM_Core_DAO_Address { //call the function to sync shared address self::processSharedAddress($address->id, $params); - //if address is already shared, share the master address with all children (prevent chaining) - if ($address->master_id > 0 && $value['id'] != $value['master_id']) { + //if address is already shared, share the master address with all children (prevent chaining) CRM-21214 + if ($address->master_id > 0 && $address->master_id != $address->id ) { $result = civicrm_api3('Address', 'get', array( 'return' => array("contact_id"), 'master_id' => $address->id, -- 2.25.1