Skip to content

Commit

Permalink
Merge pull request #17923 from eileenmcnaughton/dedupe_return
Browse files Browse the repository at this point in the history
[REF] Tighten up function signature for dedupePair
  • Loading branch information
seamuslee001 authored Jul 31, 2020
2 parents 2aec04e + a6b7cfc commit 580d386
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions CRM/Dedupe/Merger.php
Original file line number Diff line number Diff line change
Expand Up @@ -935,7 +935,8 @@ public static function merge($dupePairs = [], $cacheParams = [], $mode = 'safe',
unset($dupePairs[$index]);
continue;
}
if (($result = self::dedupePair($dupes, $mode, $checkPermissions, $cacheKeyString)) === FALSE) {
CRM_Utils_Hook::merge('flip', $dupes, $dupes['dstID'], $dupes['srcID']);
if (($result = self::dedupePair((int) $dupes['dstID'], (int) $dupes['srcID'], $mode, $checkPermissions, $cacheKeyString)) === FALSE) {
unset($dupePairs[$index]);
continue;
}
Expand Down Expand Up @@ -1867,26 +1868,22 @@ public static function mergeLocations($mainId, $otherId, $migrationInfo) {
/**
* Dedupe a pair of contacts.
*
* @param array $dupes
* @param int $mainId Id of contact to keep.
* @param int $otherId Id of contact to delete.
* @param string $mode
* @param bool $checkPermissions
* @param string $cacheKeyString
*
* @return bool|array
* @throws \API_Exception
* @throws \CRM_Core_Exception
* @throws \CRM_Core_Exception_ResourceConflictException
* @throws \CiviCRM_API3_Exception
* @throws \API_Exception
* @throws \Civi\API\Exception\UnauthorizedException
*/
protected static function dedupePair($dupes, $mode = 'safe', $checkPermissions = TRUE, $cacheKeyString = NULL) {
CRM_Utils_Hook::merge('flip', $dupes, $dupes['dstID'], $dupes['srcID']);
$mainId = $dupes['dstID'];
$otherId = $dupes['srcID'];
protected static function dedupePair(int $mainId, int $otherId, $mode = 'safe', $checkPermissions = TRUE, $cacheKeyString = NULL) {
$resultStats = [];

if (!$mainId || !$otherId) {
// return error
return FALSE;
}
$migrationInfo = [];
$conflicts = [];
// Try to lock the contacts before we load the data as we don't want it changing under us.
Expand Down

0 comments on commit 580d386

Please sign in to comment.