Dedupe ignores phone number from Drupal-Webforms and Contact Import depending on Civi version at rule creation
Old rules found in table civicrm_dedupe_rule specify the rule_field 'phone', while rules created in more recent versions of Civi specify 'phone_numeric'.
In addition, there is some inconsistency in how the phone value is received in the $params arguement of CRM/Dedupe/Finder.php:dupesByParams:
-
webform_civicrm passes:
$params['civicrm_phone']['phone'] = "123-456-7890" (raw text string)
-
Contact import passes:
$params['civicrm_phone']['phone_numeric'] = "123-456-7890" (raw text string)
In the dupesByParams function, there is a block which replaces the ['phone_numeric'] value with its numeric version, but there is no creation of ['phone_numeric'] if there exists only ['phone'].
This results in two conditions in which dedup ignores the phone number:
- Webform submissions with new rules, because the rule specifies['phone_numeric'].
- Contact import with old rules, because the rule specifies ['phone'].
I propose two changes to solve both these problems:
- Upon upgrade, replace all occurences of 'phone' in civicrm_dedupe_rule.rule_field with 'phone_numeric'.
- If passed only ['phone'] and not ['phone_numeric'], create the latter as shown in the following patch (based on the current Jun 11 917acf6f commit):
--- 917acf6/CRM/Dedupe/Finder.php
+++ new/CRM/Dedupe/Finder.php
@@ -146,6 +146,9 @@
}
$params['check_permission'] = CRM_Utils_Array::value('check_permission', $params, TRUE);
+ if (isset($params['civicrm_phone']['phone']) && !isset($params['civicrm_phone']['phone_numeric'])) {
+ $params['civicrm_phone']['phone_numeric'] = $params['civicrm_phone']['phone'];
+ }
if (isset($params['civicrm_phone']['phone_numeric'])) {
$orig = $params['civicrm_phone']['phone_numeric'];
$params['civicrm_phone']['phone_numeric'] = preg_replace('/[^\d]/', '', $orig);
Problems identified and solution tested in Civi 5.4.0.