From c131d228eec7b103189dde8a32b866400e2810d2 Mon Sep 17 00:00:00 2001 From: eileenmcnaugton Date: Thu, 16 May 2019 18:40:13 +1200 Subject: [PATCH] Remove extraneous variable 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 | 13 ++++++------- CRM/Dedupe/Merger.php | 4 +--- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/CRM/Core/BAO/PrevNextCache.php b/CRM/Core/BAO/PrevNextCache.php index bca6a1824b..bdc8e44ba1 100644 --- a/CRM/Core/BAO/PrevNextCache.php +++ b/CRM/Core/BAO/PrevNextCache.php @@ -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']; diff --git a/CRM/Dedupe/Merger.php b/CRM/Dedupe/Merger.php index 6703e57a7c..6cb8c75777 100644 --- a/CRM/Dedupe/Merger.php +++ b/CRM/Dedupe/Merger.php @@ -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); } } -- 2.25.1