Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix inconsistencies in duplicate retrieval #15160

Merged
merged 1 commit into from
Sep 2, 2019

Conversation

eileenmcnaughton
Copy link
Contributor

@eileenmcnaughton eileenmcnaughton commented Aug 29, 2019

Overview

Alternative to
Fix dedupe bug whereby the result of passing in criteria with no matches is to have it ignored
#15158
and

Performance improvement on dedupe find

#15153

as on further digging I realised that making the code more sensible would address both

Before

$pairs = $this->callAPISuccess('Dedupe', 'getduplicates', [
'rule_group_id' => 1,
'criteria' => ['contact' => ['id' => ['>' => 1000000000]]],
])
returns results if no contacts in the DB match the criteria

In addition the above query runs without a limit even when one is specified.

After

Above only returns results if contacts in the DB match the criteria.

The search_limit is respected when retrieving the contacts to match

Technical Details

Dedupe.getduplicates and duplicates retrieval in general respect 2 types of limit

 $pairs = $this->callAPISuccess('Dedupe', 'getduplicates', [
      'rule_group_id' => 1,
      'options' => ['limit' => 1],
     'criteria' => ['contact' => ['first_name' => 'Bob]],
    ])

Will fill the prevnext_cache with all pairs of contacts where one of the contacts match the criteria - ie first if finds all Bobs, then it fills the catch with all matches found for any of those Bobs given the rule. The api call returns ONLY the first pair due to limit => 1

 $pairs = $this->callAPISuccess('Dedupe', 'getduplicates', [
      'rule_group_id' => 1,
      'search_limit'  => 1,
     'criteria' => ['contact' => ['first_name' => 'Bob]],
    ])

Will find the first bob (search_limit is 1) and fill the prevnext_cache with all matches for that Bob and return as many pairs as it found

Comments

@pfigel another

@civibot
Copy link

civibot bot commented Aug 29, 2019

(Standard links)

Alternative to
civicrm#15158
and

civicrm#15153

fixing both the  inconsistency & performance & making code more legible
@eileenmcnaughton
Copy link
Contributor Author

test this please

Copy link
Contributor

@pfigel pfigel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one looks like the cleanest fix, 👍

(CiviCRM Review Template WORD-1.2)

  • General standards
    • (r-explain) PASS
    • (r-user) PASS: No UI-visible impact in core
    • (r-doc) PASS
    • (r-run) PASS: Tested various combinations with/without limit/criteria. Confirmed core UI is still functional (search, merge, filtering results)
  • Developer standards
    • (r-tech) PASS:
      • Signature of CRM_Dedupe_Finder::dupes changed; all calls in core are compatible, universe shows no incompatible calls either
      • Change where non-matching criteria causes criteria to be ignored technically changes the contract but is a bugfix that restores sanity and fixes performance
    • (r-code) PASS
    • (r-maint) PASS: Adds some tests
    • (r-test) PASS

@eileenmcnaughton
Copy link
Contributor Author

Thanks @pfigel I'm sure this caused you some brain pain too :-) But the code is inching towards sanity

@eileenmcnaughton eileenmcnaughton merged commit 957b11f into civicrm:master Sep 2, 2019
@eileenmcnaughton eileenmcnaughton deleted the dedupe8 branch September 2, 2019 20:56
wmfgerrit pushed a commit to wikimedia/wikimedia-fundraising-crm that referenced this pull request Sep 3, 2019
This is intended to address the test fail in https://gerrit.wikimedia.org/r/#/c/wikimedia/fundraising/crm/civicrm/+/533134/

We need to have the right permission for the test to pass once the 'supporting bug' is fixed, and it turns out
we didn't

Fix  inconsistencies in duplicate retrieval

I've submitted this upstream at
civicrm/civicrm-core#15160

Alternative to
civicrm/civicrm-core#15158
and

civicrm/civicrm-core#15153

fixing both the  inconsistency & performance & making code more legible

Bug: T228826
Change-Id: Ie636d13ac05117b3fbce4c07e463c76e27fb764b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants