Skip to content

Commit

Permalink
Pass all available relevant fields to Contact.getduplicates on checkM…
Browse files Browse the repository at this point in the history
…atchingContact

I took a look at #23353 in the hopes of resolving it
but it's really tricky code & there were a couple of trade offs in there I wasn't comfortable with

1) losing the faster ajax call
2) letting more worms out than absolutely necessary

OTOH that patch is a bit cleverer I think in terms of not double presenting contacts.
  • Loading branch information
eileenmcnaughton committed Mar 1, 2024
1 parent 1864c7b commit b2f080d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
20 changes: 19 additions & 1 deletion CRM/Contact/Form/Contact.php
Original file line number Diff line number Diff line change
Expand Up @@ -805,7 +805,25 @@ public function buildQuickForm() {
$this->assign('checkSimilar', $checkSimilar);
if ($checkSimilar == 1) {
$ruleParams = ['used' => 'Supervised', 'contact_type' => $this->_contactType];
$this->assign('ruleFields', CRM_Dedupe_BAO_DedupeRule::dedupeRuleFields($ruleParams));
// These are the fields tht are passed to apiv3 Contact.getduplicates.
// Most likely it is enough to pass only the fields returned from the function but
// this code has been a bit flip-floppy with the ruleFields removed in favour of
// the hard-coded list below here
// https://github.com/civicrm/civicrm-core/commit/01ee39a0165a6f3fdc8b105626abaa9cb951bb3f#diff-eee833728c23038f8ac3e2bbb37bef5fa1f718d327896178ae9526c31ee80672L265-R273
// at that point the api was switched here https://github.com/civicrm/civicrm-core/commit/01ee39a0165a6f3fdc8b105626abaa9cb951bb3f#diff-eee833728c23038f8ac3e2bbb37bef5fa1f718d327896178ae9526c31ee80672R311
// However, it was at least partially switched back here https://github.com/civicrm/civicrm-core/commit/a7ba493ce752fee7b05daa103bc1c956b7d05b0f#diff-eee833728c23038f8ac3e2bbb37bef5fa1f718d327896178ae9526c31ee80672R334
// so deliberately erring on the side of passing too much information in hopes of breaking
// the wheel.
$ruleFields = array_unique(CRM_Dedupe_BAO_DedupeRule::dedupeRuleFields($ruleParams)
+ [
'first_name',
'last_name',
'nick_name',
'household_name',
'organization_name',
'email'
]);
$this->assign('ruleFields', json_encode($ruleFields));
}

// build Custom data if Custom data present in edit option
Expand Down
9 changes: 1 addition & 8 deletions templates/CRM/Contact/Form/Contact.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -244,14 +244,7 @@
{/literal}{* Ajax check for matching contacts *}
{if $checkSimilar == 1}
var contactType = {$contactType|@json_encode},
rules = {*$ruleFields|@json_encode*}{literal}[
'first_name',
'last_name',
'nick_name',
'household_name',
'organization_name',
'email'
],
rules = {$ruleFields}{literal},
ruleFields = {},
$ruleElements = $(),
matchMessage,
Expand Down

0 comments on commit b2f080d

Please sign in to comment.