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#723 Fix fatal error when trying to merge contacts with a cus… #14325

Merged
merged 1 commit into from
May 30, 2019

Conversation

eileenmcnaughton
Copy link
Contributor

@eileenmcnaughton eileenmcnaughton commented May 24, 2019

Overview

Fixes a fatal error when trying to merge 2 contacts with custom fields of type file

Before

Fatal error

After

Merge succeeds

Technical Details

As discussed by @lcdservices in gitlab we have a problem where custom fields are dealt with in multiple places - & on at least 2 types (file & country) they are not successfullly merged. My big picture proposal is to move all handling of custom field moves to a new 'move' function. This would mean that we no longer create & format a $submitted array for them, removing a lot of code, and probably we would be able to stop calling the profile.create function - removing complexity in favour of a simple api call for the contact fields.

One downside is the profile.create hook would be bypassed. I think that's OK - I have never heard anyone say they use it. But we could consider making the move function a pattern with it's own hook . - I also think it should be api-exposed since 'arg I want to move a contribution from this contact to that' is a 'thing' & the BAO doesn't provide generic helpers as yet

Comments

@civibot
Copy link

civibot bot commented May 24, 2019

(Standard links)

@eileenmcnaughton
Copy link
Contributor Author

@lcdservices are you able to test this?

@twomice
Copy link
Contributor

twomice commented May 29, 2019

Reviewing this now.

Copy link
Contributor

@twomice twomice left a comment

Choose a reason for hiding this comment

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

(CiviCRM Review Template WORD-1.2)

  • General standards
    • (r-explain) Issue: minor typos/grammar/clarification in code comments; see my review comments.
    • (r-user) Pass:
    • (r-doc) Pass
    • (r-run) Pass:
      • Verified the issue exists in master, reproduced with steps in dev/core#723: observed fatal error as described.
      • After applying PR, repeated same steps, and observed:
        • no fatal error
        • file was correctly moved to surviving contact in merge.
  • Developer standards
    • (r-tech) Issue:
      • The PR "Technical Details" mentions that "the profile.create hook would be bypassed"; does this refer to hook_civicrm_post() and hook_civicrm_pre() ? I'm not aware of the likely impact of this change, and it's hard to cr; could be worth a PSA to extension developers.
    • (r-code) Pass
    • (r-maint) Pass: PR includes changes to an existing test, which is passing.
    • (r-test) Pass

$oldContact = civicrm_api3('Contact', 'getsingle', ['id' => $oldContactID, 'return' => $return]);
$newContact = civicrm_api3('Contact', 'getsingle', ['id' => $newContactID, 'return' => $return]);

// The moveaAllBelongings function has functionality to move custom fields. It doesn't work very well...
Copy link
Contributor

Choose a reason for hiding this comment

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

typo "moveaAllBelongings" should be "moveAllBelongings" ?

@@ -2146,29 +2148,36 @@ protected static function swapOutFieldsAffectedByQFZeroBug(&$migrationInfo) {
/**
* Honestly - what DOES this do - hopefully some refactoring will reveal it's purpose.
*
* Update this is formatting fields to be processed through 'ProfileContactCreate action
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm unsure of the meaning of this line/sentence. Could it be edited for clarity?

@eileenmcnaughton
Copy link
Contributor Author

@twomice thanks - I've update the comments you pointed to. Regarding switching to not using profile create - this PR doesn't actually make that change but yes perhaps if once soon does we should send a PSA

@twomice
Copy link
Contributor

twomice commented May 30, 2019

@eileenmcnaughton Thanks for the work on this -- I am very happy (and surely it's not just me) to see this getting resolved. Thanks for explaining about the hook; I just assumed I was missing something there.

So I'm approving this as officially as I can here. Anything else I can do to help get this merged?

@eileenmcnaughton
Copy link
Contributor Author

Thanks @twomice - I'll merge it - I'm gonna take this a bit further so hopefully you will review the follow ups too

@eileenmcnaughton eileenmcnaughton merged commit c3f693f into civicrm:master May 30, 2019
@eileenmcnaughton eileenmcnaughton deleted the merge_cust_field branch May 30, 2019 21:31
@twomice
Copy link
Contributor

twomice commented May 31, 2019

Yes, hopefully.

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