CRM_Dedupe_Finder parses phone key incorrectly
Overview
A profile input form that matches on Phone-Main-Mobile (and I suspect on any phone) sends CRM_Dedupe_Finder::formatParams an input like '["phone-3-1"] => "3214567890"' which after the relevant code around line 255 yields ["phone-3"]. This doesn't match the "phone" in CRM_Dedupe_BAO_RuleGroup::supportedFields so the duplicate check fails.
I patched this by replacing the regular expression in line 255 https://github.com/civicrm/civicrm-core/blob/master/CRM/Dedupe/Finder.php#L255
-
From:
'/(.*)-(Primary-[\d+])$|(.*)-(\d+|Primary)$/'
-
To:
'/(.*)-(Primary-[\d+])$|(.*)-(\d+-\d+)$|(.*)-(\d+|Primary)$/'
https://civicrm.stackexchange.com/q/35672/5446
Reproduction steps
- Create individual unsupervised rule that matches on phone
- Create input profile that creates contact with phone-main-mobile and set to "Update the matching contact" on duplicate match
- Create multiple contacts with same phone
Current behaviour
Creates duplicate contacts
Expected behaviour
Update pre-existing contact
Environment information
- CiviCRM: 5.25.0
Comments
I expect you'd prefer I do what's called a "pull request." Apologies, I'm an old retired guy who hasn't programmed for a living in over 35 years so all this new fangled stuff intimidates me. This was an act of desperation on behalf of the nonprofit I volunteer for.
@jaapjansma has created the PR: https://github.com/civicrm/civicrm-core/pull/17361