From e908d4ab1ad4cbecd768b4f27ad522c5adc83932 Mon Sep 17 00:00:00 2001 From: eileen Date: Wed, 31 Mar 2021 13:17:58 +1300 Subject: [PATCH] [REF] Minor cleanup Makes typing a bit stricter, uses preferred strpos function --- CRM/Dedupe/Merger.php | 14 +++++++------- api/v3/Contact.php | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/CRM/Dedupe/Merger.php b/CRM/Dedupe/Merger.php index 59bc053582..13beca29c6 100644 --- a/CRM/Dedupe/Merger.php +++ b/CRM/Dedupe/Merger.php @@ -657,7 +657,7 @@ INNER JOIN civicrm_membership membership2 ON membership1.membership_type_id = m // 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); + [$data] = CRM_Contact_BAO_Contact::formatProfileContactParams($params, [], $contactID); CRM_Contact_BAO_Contact::create($data); } @@ -1021,7 +1021,7 @@ INNER JOIN civicrm_membership membership2 ON membership1.membership_type_id = m */ public static function skipMerge($mainId, $otherId, &$migrationInfo, $mode = 'safe', &$conflicts = []) { - $conflicts = self::getConflicts($migrationInfo, $mainId, $otherId, $mode)['conflicts']; + $conflicts = self::getConflicts($migrationInfo, (int) $mainId, (int) $otherId, $mode)['conflicts']; // A hook could have set skip_merge in order to alter merge behaviour. // This is a something we might ideally deprecate since they really 'should' // mess with the conflicts array instead. @@ -1236,7 +1236,7 @@ INNER JOIN civicrm_membership membership2 ON membership1.membership_type_id = m $locations = ['main' => [], 'other' => []]; foreach ($locationBlocks as $blockName => $blockInfo) { - list($locations, $rows, $elements, $migrationInfo) = self::addLocationFieldInfo($mainId, $otherId, $blockInfo, $blockName, $locations, $rows, $elements, $migrationInfo); + [$locations, $rows, $elements, $migrationInfo] = self::addLocationFieldInfo($mainId, $otherId, $blockInfo, $blockName, $locations, $rows, $elements, $migrationInfo); } // End loop through each location block entity // add the related tables and unset the ones that don't sport any of the duplicate contact's info @@ -1454,7 +1454,7 @@ INNER JOIN civicrm_membership membership2 ON membership1.membership_type_id = m $submitted = []; } foreach ($submitted as $key => $value) { - list($cFields, $submitted) = self::processCustomFields($mainId, $key, $cFields, $submitted, $value); + [$cFields, $submitted] = self::processCustomFields($mainId, $key, $cFields, $submitted, $value); } // move view only custom fields CRM-5362 @@ -2119,7 +2119,7 @@ INNER JOIN civicrm_membership membership2 ON membership1.membership_type_id = m * @throws \CRM_Core_Exception * @throws \CiviCRM_API3_Exception */ - public static function getConflicts(&$migrationInfo, $mainId, $otherId, $mode) { + public static function getConflicts(array &$migrationInfo, int $mainId, int $otherId, string $mode): array { $conflicts = []; // Generate var $migrationInfo. The variable structure is exactly same as // $formValues submitted during a UI merge for a pair of contacts. @@ -2138,8 +2138,8 @@ INNER JOIN civicrm_membership membership2 ON membership1.membership_type_id = m continue; } elseif ((in_array(substr($key, 5), CRM_Dedupe_Merger::getContactFields()) or - substr($key, 0, 12) === 'move_custom_' - ) and $val != NULL + strpos($key, 'move_custom_') === 0 + ) and $val !== NULL ) { // Rule: If both main-contact, and other-contact have a field with a // different value, then let $mode decide if to merge it or not diff --git a/api/v3/Contact.php b/api/v3/Contact.php index 8217b646d1..2b82060958 100644 --- a/api/v3/Contact.php +++ b/api/v3/Contact.php @@ -1228,7 +1228,7 @@ function civicrm_api3_contact_get_merge_conflicts($params) { foreach ((array) $params['mode'] as $mode) { $result[$mode] = CRM_Dedupe_Merger::getConflicts( $migrationInfo, - $params['to_remove_id'], $params['to_keep_id'], + (int) $params['to_remove_id'], (int) $params['to_keep_id'], $mode ); } -- 2.25.1