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

dev/core#3850 Fix checkboxes handling for custom fields in contact import #24848

Merged
merged 1 commit into from
Oct 31, 2022

Conversation

eileenmcnaughton
Copy link
Contributor

@eileenmcnaughton eileenmcnaughton commented Oct 28, 2022

Overview

dev/core#3850 Fix checkboxes handling for custom fields in contact import

Before

Per https://lab.civicrm.org/dev/core/-/issues/3850 multiple item checkboxes are mis-saved in Contact import

After

Save correctly (description on gitlab of steps)

Technical Details

This code has 'evolved' from what was originally probably a copy & paste of the form layer. The function formatProfileContact was used to to prepare values that had been lovingly crafted into form-like format to be passed to the `BAO_Contact::create'.

Over time the function started to call the api instead of Contact::create making much of what was happening in formatProfileContact redundant. Because that function was serving multiple masters & crazy-complex a copy of the function was taken & it was moved onto the import class where we could start to unravel it (knowing ti would only affect import). However the function still contains much code that grew up for it's other use-cases, rather than import.

Paralell to that $params = $this->getMappedRow($values); evolved into a function which generally took the input & returned it in an api-ready format.

Hence the go-to solution for any import data format related issues is to try removing code :-)

In this case the worker function CRM_Core_BAO_CustomField::formatCustomField is already called in the api - but along the way handing was added for exactly this type of field - so if we just let the api do the work the bug is fixed

Comments

@civibot
Copy link

civibot bot commented Oct 28, 2022

(Standard links)

@civibot civibot bot added the 5.55 label Oct 28, 2022
@eileenmcnaughton eileenmcnaughton changed the title dev/core#3850 Fix checkbox import dev/core#3850 Fix checkboxes handling for custom fields in contact import Oct 28, 2022
@jmcclelland
Copy link
Contributor

Thank you @eileenmcnaughton! I love fixing problems by deleting code :).

I just tested this change against 5.51.3 (on a site previously experiencing the problem) and it worked perfectly after applying this patch.

@andyburnsco
Copy link
Contributor

Confirmed this also works on 5.54.0. Thanks @eileenmcnaughton :)

@colemanw colemanw merged commit b3c3e52 into civicrm:5.55 Oct 31, 2022
@colemanw colemanw deleted the import_box branch October 31, 2022 18:42
@eileenmcnaughton eileenmcnaughton mentioned this pull request Nov 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants