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 Dedupe entity_tag mangling bug #17125

Merged
merged 1 commit into from
Apr 29, 2020
Merged

Conversation

eileenmcnaughton
Copy link
Contributor

@eileenmcnaughton eileenmcnaughton commented Apr 21, 2020

Overview

Fixes a bug whereby the merge script alters non-contact entity tags, changing the entity they are related to

Before

Start with a contact & an activity with the same id

Assign a contact entity tag to the contact and an activity entity tag to the activity.

Merge the contact with another contact, note that the entity_id is updated on the activity entity_tag too

After

Only the contact entity tag is updated.

Technical Details

I identified this bug in testing removing the UPDATE IGNORE + DELETE in #17072.

entity_tag is hack-added to the array of tables that interact with contact - resulting in it passing through the UPDATE without the WHERE entity_table = ...

The function with the hack-add is called from 2 places. We know it is unwanted in 1 so I moved it to the other place (being unsure if it is useful there this should give no change)

civicrm_entity_tag was missing from the array of tables that are entity_table-linked to contacts. I switched to using discovery rather than hard-coding but I added caching to limit it to once per batch script

Comments

@pfigel

@civibot
Copy link

civibot bot commented Apr 21, 2020

(Standard links)

@civibot civibot bot added the master label Apr 21, 2020
@eileenmcnaughton eileenmcnaughton force-pushed the dupe1 branch 4 times, most recently from f8215d8 to 1b67a7a Compare April 22, 2020 05:55
@eileenmcnaughton
Copy link
Contributor Author

@pfigel will you be able to look at this?

@pfigel
Copy link
Contributor

pfigel commented Apr 28, 2020

@eileenmcnaughton will take a look at this today or tomorrow.

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.

That's a nasty one - I'm sure we've been bitten by it but never noticed. Thanks @eileenmcnaughton!

  • General standards
    • (r-explain) PASS
    • (r-user) PASS: User would expect tags with unrelated entities not to be touched by a merge.
    • (r-doc) PASS
    • (r-run) PASS: Test scenarios:
      • ✅ Tag on activity where entity_id was colliding with the merged contact wasn't updated.
      • civicrm_entity_file row attached to the merged contact was updated correctly
      • ✅ No broader issues with merge screen/results found
  • Developer standards
    • (r-tech) PASS: More standardization. Signature change on CRM_Dedupe_Merger::moveContactBelongings() likely has no ecosystem impact (no universe matches).
    • (r-code) PASS
    • (r-maint) PASS
    • (r-test) PASS

@seamuslee001 seamuslee001 merged commit 25b9830 into civicrm:master Apr 29, 2020
@seamuslee001 seamuslee001 deleted the dupe1 branch April 29, 2020 09:35
@eileenmcnaughton
Copy link
Contributor Author

@pfigel we have probably been hit too. I only found it because I saw alarming queries run on our server 'DELETE FROM civicrm_contact WHERE employer_id = x' - which led me to #17072 & then this

@MegaphoneJon
Copy link
Contributor

Is there a Gitlab issue for this?

@eileenmcnaughton
Copy link
Contributor Author

maybe not - there was a bunch of refactors & this was found adding a test

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.

4 participants