Skip to content

Commit

Permalink
[REF] Reduce interaction between dedupe code and createProfileContact
Browse files Browse the repository at this point in the history
Ideally we want to simply call apiv4 from the deduper. However, it seems to take a bit of analysis to determine
if anything is done in there that might have some impact. This takes one step in that direction.  I copied the full function over
and then remove all the parts that are unreachable due to the passed in params or meaningless due to us not having Billing
fields. I think the Profile hooks are overkill - the merge hooks and contact hooks are being run and no profile is being submitted
  • Loading branch information
eileenmcnaughton committed Jul 23, 2020
1 parent 7526f12 commit d00dc57
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions CRM/Dedupe/Merger.php
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,30 @@ protected static function filterRowBasedCustomDataFromCustomTables(array &$cidRe
}
}

/**
* Update the contact with the new parameters.
*
* This function is intended as an interim function, with the intent being
* an apiv4 call.
*
* The function was calling the rather-terrifying createProfileContact. I copied all
* that code into this function and then removed all the parts that have no effect in this scenario.
*
* @param int $contactID
* @param array $params
*
* @throws \CRM_Core_Exception
* @throws \CiviCRM_API3_Exception
* @throws \Civi\API\Exception\UnauthorizedException
*/
protected static function createContact($contactID, $params) {
// This parameter causes blank fields to be be emptied out.
// We can probably remove.
$params['updateBlankLocInfo'] = TRUE;
list($data) = CRM_Contact_BAO_Contact::formatProfileContactParams($params, [], $contactID);
CRM_Contact_BAO_Contact::create($data);
}

/**
* Given a contact ID, will check if a record exists in given table.
*
Expand Down Expand Up @@ -1450,8 +1474,7 @@ public static function moveAllBelongings($mainId, $otherId, $migrationInfo, $che
if (!isset($submitted['suffix_id']) && !empty($migrationInfo['main_details']['suffix_id'])) {
$submitted['suffix_id'] = $migrationInfo['main_details']['suffix_id'];
}
$null = [];
CRM_Contact_BAO_Contact::createProfileContact($submitted, $null, $mainId);
self::createContact($mainId, $submitted);
}
$transaction->commit();
CRM_Utils_Hook::post('merge', 'Contact', $mainId);
Expand Down

0 comments on commit d00dc57

Please sign in to comment.