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 fatal when saving import mapping with a relationship but 'Primary' location type #15115

Merged
merged 1 commit into from
Sep 5, 2019

Conversation

eileenmcnaughton
Copy link
Contributor

@eileenmcnaughton eileenmcnaughton commented Aug 23, 2019

Overview

Fixes a fatal error when saving an import mapping with field mapped to (for example) employer's phone with the location type set to primary

Mapping looks like this (bottom field is the issue)
Screen Shot 2019-08-23 at 4 11 33 PM

Before


Screen Shot 2019-08-23 at 3 20 35 PM

After

Saves

Technical Details

This occurs because the correct value to save for location_type_id of Primary is '' but the current code winds up casting to 0
which won't save as it there is a foreign key involved. Handling was previously added but only to the
(duplicate) code that deals with non-relationship fields

https://github.com/eileenmcnaughton/civicrm-core/blob/cd41fa5b5599b329bd6f54acf0a79dda85477804/CRM/Contact/Import/Form/MapField.php#L724

Comments

…' relationship type

This occurs because the correct value to save for location_type_id of Primary is '' but the current code winds up casting to 0
which won't save as it there is a foreign key involved.  Handling was previously added but only to the
(duplicate) code that deals with non-relationship fields

https://github.com/eileenmcnaughton/civicrm-core/blob/cd41fa5b5599b329bd6f54acf0a79dda85477804/CRM/Contact/Import/Form/MapField.php#L724
@civibot
Copy link

civibot bot commented Aug 23, 2019

(Standard links)

@yashodha
Copy link
Contributor

@eileenmcnaughton Are all the fields necessary to replicate? If not, can you highlight the one causing DB error.

@eileenmcnaughton
Copy link
Contributor Author

@yashodha no - I mentioned above the bottom field is causing the issue - that is the only one necessary to replicate

@eileenmcnaughton
Copy link
Contributor Author

@jitendrapurohit are you able to review this?

Copy link
Contributor

@jitendrapurohit jitendrapurohit left a comment

Choose a reason for hiding this comment

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

Replicated and confirm that the issue is fixed by the changes done here. Also tested the outcome of the location type after import.

@eileenmcnaughton
Copy link
Contributor Author

thanks @jitendrapurohit -merging

@eileenmcnaughton eileenmcnaughton merged commit bc523fd into civicrm:master Sep 5, 2019
@eileenmcnaughton eileenmcnaughton deleted the import_metadata branch January 7, 2020 02:58
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.

3 participants