Details
Description
Follow-up from CRM-19653. This is critical because it causes data errors.
Summary: Custom field values are migrated even when not specifically told to during the merge process.
Steps to recreate:
Create a custom checkbox field with two options, '1' and '2'.
Create 'contact main' using the API, eg:
'contact_type' => "Individual", 'last_name' => "Main", 'first_name' => "Contact",
Create 'contact duplicate using the API, including '1' in the custom field, eg:
'contact_type' => "Individual", "last_name": "Duplicate", "first_name": "Contact", "custom_9": 1
Merge the two contacts, with the 'main' contact on the right - do not select anything to take across
Expected result: No custom field value
Actual result: '1' in the custom field
Visual representation: https://issues.civicrm.org/jira/secure/attachment/60773/60773_issue-2-merged-regardless.jpg
Mitigation: The error only occurs if the 'main' contact 'never' had any of the custom values in the set.
Analysis: This seems to stem from the second call to the moveContactBelongings function here: https://github.com/civicrm/civicrm-core/blob/cd86a3ba16f244a9168aeb14cdfc43138e071e66/CRM/Dedupe/Merger.php#L1486 which 'moves' all the custom field values from the duplicate to the main, regardless of what was selected on the form. This issue is the case with all custom fields, not just checkboxes.
Attachments
Issue Links
- supplements
-
CRM-19653 Custom field checkboxes migrated incorrectly on merge (part deux)
- Done/Fixed
- links to