Skip to content

Commit

Permalink
Fix crashes when 'null' string is passed in via API
Browse files Browse the repository at this point in the history
  • Loading branch information
mattwire committed Nov 24, 2017
1 parent 0dc0739 commit c42166b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions CRM/Core/BAO/Address.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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 (!CRM_Utils_System::isNull($address->master_id)) {
$values['use_shared_address'] = 1;
}

Expand Down Expand Up @@ -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']);
}
Expand All @@ -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);
Expand Down

0 comments on commit c42166b

Please sign in to comment.