Uploaded image for project: 'CiviCRM'
  1. CiviCRM
  2. CRM-20858

Custom fields migrated even when not asked during merge

    Details

    • Type: Bug
    • Status: Done/Fixed
    • Priority: Critical
    • Resolution: Fixed/Completed
    • Affects Version/s: 4.7.23
    • Fix Version/s: 4.7.25
    • Component/s: Dedupe
    • Labels:
    • Versioning Impact:
      Patch (backwards-compatible bug fixes)
    • Documentation Required?:
      None
    • Funding Source:
      Contributed Code
    • Verified?:
      No

      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

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              john John K.
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: