Merge pull request #17923 from eileenmcnaughton/dedupe_return
authorSeamus Lee <seamuslee001@gmail.com>
Fri, 31 Jul 2020 23:38:27 +0000 (09:38 +1000)
committerGitHub <noreply@github.com>
Fri, 31 Jul 2020 23:38:27 +0000 (09:38 +1000)
[REF] Tighten up function signature for dedupePair

CRM/Dedupe/Merger.php

index 1a918695103c68e36e98001a8d0d4a0094335417..088437f1a1a610237f7474020aea27a9b08e8e0a 100644 (file)
@@ -935,7 +935,8 @@ INNER JOIN  civicrm_membership membership2 ON membership1.membership_type_id = m
           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;
         }
@@ -1867,26 +1868,22 @@ INNER JOIN  civicrm_membership membership2 ON membership1.membership_type_id = m
   /**
    * 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.