Remove extraneous variable
authoreileenmcnaugton <emcnaughton@wikimedia.org>
Thu, 16 May 2019 06:40:13 +0000 (18:40 +1200)
committereileenmcnaugton <emcnaughton@wikimedia.org>
Thu, 16 May 2019 06:45:14 +0000 (18:45 +1200)
Delete Pair is only called from one place in the code & it does not pass the $entityTable
variable - so remove it & reduce complexity.

In addition the viceVersa variable is always true so we can remove this too.

CRM/Core/BAO/PrevNextCache.php
CRM/Dedupe/Merger.php

index bca6a1824bb2d9c9a21ca48d266446fc9113578d..bdc8e44ba131789db47434a891c315add1098a43 100644 (file)
@@ -138,19 +138,18 @@ WHERE  cacheKey     = %3 AND
   }
 
   /**
-   * Delete from the previous next cache table for a pair of ids.
+   * Delete pair from the previous next cache table to remove it from further merge consideration.
+   *
+   * The pair may have been flipped, so make sure we delete using both orders
    *
    * @param int $id1
    * @param int $id2
    * @param string $cacheKey
-   * @param bool $isViceVersa
-   * @param string $entityTable
    */
-  public static function deletePair($id1, $id2, $cacheKey = NULL, $isViceVersa = FALSE, $entityTable = 'civicrm_contact') {
-    $sql = "DELETE FROM civicrm_prevnext_cache WHERE  entity_table = %1";
-    $params = [1 => [$entityTable, 'String']];
+  public static function deletePair($id1, $id2, $cacheKey = NULL) {
+    $sql = "DELETE FROM civicrm_prevnext_cache WHERE  entity_table = 'civicrm_contact'";
 
-    $pair = !$isViceVersa ? "entity_id1 = %2 AND entity_id2 = %3" : "(entity_id1 = %2 AND entity_id2 = %3) OR (entity_id1 = %3 AND entity_id2 = %2)";
+    $pair = "(entity_id1 = %2 AND entity_id2 = %3) OR (entity_id1 = %3 AND entity_id2 = %2)";
     $sql .= " AND ( {$pair} )";
     $params[2] = [$id1, 'Integer'];
     $params[3] = [$id2, 'Integer'];
index 6703e57a7cda0e1c7a73a94f5cce7343c2a497ac..6cb8c757777c56beca5b0a46a68c8007806c7e4d 100644 (file)
@@ -2155,9 +2155,7 @@ INNER JOIN  civicrm_membership membership2 ON membership1.membership_type_id = m
       CRM_Core_BAO_PrevNextCache::markConflict($mainId, $otherId, $cacheKeyString, $conflicts);
     }
     else {
-      // delete entry from PrevNextCache table so we don't consider the pair next time
-      // pair may have been flipped, so make sure we delete using both orders
-      CRM_Core_BAO_PrevNextCache::deletePair($mainId, $otherId, $cacheKeyString, TRUE);
+      CRM_Core_BAO_PrevNextCache::deletePair($mainId, $otherId, $cacheKeyString);
     }
   }