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 CRM-21832 - Recurring activities don't carry over custom datas & add test provided by Agileware #14183

Merged
merged 1 commit into from
May 7, 2019

Conversation

eileenmcnaughton
Copy link
Contributor

@eileenmcnaughton eileenmcnaughton commented May 2, 2019

Overview

Fixes a bug where custom fields are not copied over when copying an entity. This is in order to resolve #13470 which had a useful test. I've left the part about the tags out of scope & commented it out in the test but it would be easy now for someone to pick it up

Before

Copying most entities does not copy custom fields

After

Generic code to copy custom fields in copyGeneric

Technical Details

Per #13470 custom fields are
inconsistently copied where copying entities. This makes the code from
BAO_Event called from the genericCopy function.

I did a bit of an audit and the places where this is currently called from don't appear
to call the copyGeneric function with the 'custom' param that would have activated the old
code. I also consistently removed the & when it was being called so I could take it
out of the signature.

The original PR handled tags as well, but not in a generic way. I've left that out of scope
but the test is present, commented out, so it would be easy enough to revist

After some grepping I deprecated a function

Comments

#13470 seemed irrevocably stalled but @mattwire had left pretty clear guidance in his reviewer comment so I just did his step one & it all kinda fell into place. I didn't use the original code from that PR but I DID use the unit test which was the part of the PR I was keen not to lose

@yashodha perhaps you could review & merge this?

@civibot
Copy link

civibot bot commented May 2, 2019

(Standard links)

@civibot civibot bot added the master label May 2, 2019
@eileenmcnaughton eileenmcnaughton changed the title Fix failure to copy custom fields & add test provided by Agileware Fix CRM-21832 - Recurring activities don't carry over custom datas & add test provided by Agileware May 2, 2019
if (!empty($newData['custom'])) {
CRM_Core_BAO_CustomValueTable::store($newData['custom'], $newObject::getTableName(), $newObject->id);
}
$newObject->copyCustomFields($object->id, $newObject->id);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is the actual change

@yashodha
Copy link
Contributor

yashodha commented May 3, 2019

@eileenmcnaughton sure, will look at this

@yashodha
Copy link
Contributor

yashodha commented May 6, 2019

@eileenmcnaughton

should we also remove https://github.com/civicrm/civicrm-core/blob/master/CRM/Event/BAO/Event.php#L989

since there is already a call to copyGeneric which in turn is calling copyCustomFields resulting in duplicate calls.

Per civicrm#13470 custom fields are
inconsistently copied where copying entities. This makes the code from
BAO_Event called from the genericCopy function.

I did a bit of an audit and the places where this is currently called from don't appear
to call the copyGeneric function with the 'custom' param that would have activated the old
code. I also consistently removed the & when it was being called so I could take it
out of the signature.

The original PR handled tags as well, but not in a generic way. I've left that out of scope
but the test is present, commented out, so it would be easy enough to revist
@eileenmcnaughton
Copy link
Contributor Author

@yashodha yes - you are right! I have removed it now. Thanks

@yashodha
Copy link
Contributor

yashodha commented May 7, 2019

@eileenmcnaughton looks good and can be merged.

@yashodha yashodha merged commit 65e7186 into civicrm:master May 7, 2019
@eileenmcnaughton
Copy link
Contributor Author

Thanks @yashodha

@agilewarealok we got the custom field part of this work by you merged

@eileenmcnaughton eileenmcnaughton deleted the copy_dao branch May 7, 2019 06:13
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.

2 participants