From 6b60d8a342c5a7a0052b62b3965425b120880fcc Mon Sep 17 00:00:00 2001 From: Matthew Wire Date: Fri, 24 Nov 2017 17:39:09 +0000 Subject: [PATCH] Fix crashes when 'null' string is passed in via API --- CRM/Core/BAO/Address.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CRM/Core/BAO/Address.php b/CRM/Core/BAO/Address.php index 1d06932896b7..144b8b649d8b 100644 --- a/CRM/Core/BAO/Address.php +++ b/CRM/Core/BAO/Address.php @@ -153,7 +153,7 @@ public static function add(&$params, $fixAddress) { } // (prevent chaining 1 and 3) CRM-21214 - if (CRM_Utils_Array::value('master_id', $params)) { + if (isset($params['master_id']) && !CRM_Utils_System::isNull($params['master_id'])) { self::fixSharedAddress($params); } @@ -537,7 +537,7 @@ public static function &getValues($entityBlock, $microformat = FALSE, $fieldName $values['display'] = $address->display; $values['display_text'] = $address->display_text; - if (is_numeric($address->master_id)) { + if (isset($address->master_id) && !CRM_Utils_System::isNull($address->master_id)) { $values['use_shared_address'] = 1; } @@ -1031,7 +1031,7 @@ public static function processSharedAddress($addressId, $params) { // unset contact id $skipFields = array('is_primary', 'location_type_id', 'is_billing', 'contact_id'); - if (CRM_Utils_Array::value('master_id', $params)) { + if (isset($params['master_id']) && !CRM_Utils_System::isNull($params['master_id'])) { // call the function to create a relationship for the new shared address self::processSharedAddressRelationship($params['master_id'], $params['contact_id']); } @@ -1046,7 +1046,7 @@ public static function processSharedAddress($addressId, $params) { $addressDAO = new CRM_Core_DAO_Address(); while ($dao->fetch()) { // call the function to update the relationship - if (CRM_Utils_Array::value('master_id', $params)) { + if (isset($params['master_id']) && !CRM_Utils_System::isNull($params['master_id'])) { self::processSharedAddressRelationship($params['master_id'], $dao->contact_id); } $addressDAO->copyValues($params);