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#1838 Ensure that no fatal error is triggered if you try to a… #18564

Merged
merged 1 commit into from
Sep 29, 2020

Conversation

seamuslee001
Copy link
Contributor

…ccess a merged contact and the contact that it was merged into has been permanently deleted

Overview

Replication details are on the lab https://lab.civicrm.org/dev/core/-/issues/1838 but this seems like an easy fix

Before

Fatal error on viewing the merged contact

After

No fatal error

ping @eileenmcnaughton @andrew-cormick-dockery

@civibot
Copy link

civibot bot commented Sep 22, 2020

(Standard links)

@civibot civibot bot added the master label Sep 22, 2020
@eileenmcnaughton
Copy link
Contributor

@seamuslee001 should we be doing this in the api or the function that calls the api?

@eileenmcnaughton
Copy link
Contributor

I see it's called here

Screen Shot 2020-09-23 at 11 03 45 AM

@seamuslee001
Copy link
Contributor Author

@eileenmcnaughton hmm yeh maybe, but also I feel like the error message is not useful so catching the internal exception and throwing a new exception with a better error might be helpful right?

@eileenmcnaughton
Copy link
Contributor

@seamuslee001 yeah - so I don't think we need to log it. We should possibly return some alert to the user at the form level?

@eileenmcnaughton
Copy link
Contributor

@seamuslee001 it;s also OK to use apiv4 within apiv3 internally - we might be able to just construct the query a bit better that way?

@seamuslee001
Copy link
Contributor Author

@eileenmcnaughton i'm not looking to change anything to apiv4 here

@eileenmcnaughton
Copy link
Contributor

@seamuslee001 you could switch to get rather than getvalue

@seamuslee001
Copy link
Contributor Author

@eileenmcnaughton I have moved the exception catching into the Page and also expanded the UT to cover the page view function

@eileenmcnaughton
Copy link
Contributor

@seamuslee001 I'm OK with that - except just the stylistic thing on exception.

@eileenmcnaughton
Copy link
Contributor

@seamuslee001 jenkins....

@seamuslee001
Copy link
Contributor Author

should be sorted now @eileenmcnaughton

$mergedTo = civicrm_api3('Contact', 'getmergedto', ['contact_id' => $contactId, 'api.Contact.get' => ['return' => 'display_name']]);
}
catch (CiviCRM_API3_Exception $e) {
CRM_Core_Session::singleton()->setStatus(ts('Have not been able to determine which contact this contact merged into'), ts('Unable to determine kept contact'));
Copy link
Contributor

Choose a reason for hiding this comment

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

@seamuslee001 so my last concern is the wording here - someone like @MikeyMJCO might have an idea but maybe something longer like 'This contact was deleted in a merge but the new contact can not be determined / has since been deleted'

My main 'ug' is just the 'Have not been able' doesn't feel right - who has not....

@eileenmcnaughton
Copy link
Contributor

@MikeyMJCO any thoughts about the message wording - this is fine technically but I'm not sure the message is that good

@homotechsual
Copy link
Contributor

@MikeyMJCO any thoughts about the message wording - this is fine technically but I'm not sure the message is that good

To be clear this error is thrown when one of the contacts involved in the merge has been deleted and the attempt try to merge fails?

@seamuslee001
Copy link
Contributor Author

@MikeyMJCO this error is shown when you view a contact that is in the trash that was trashed because of a merged and the contact it was merged into is no longer on the system

@homotechsual
Copy link
Contributor

@MikeyMJCO this error is shown when you view a contact that is in the trash that was trashed because of a merged and the contact it was merged into is no longer on the system

So something along the lines of:

CRM_Core_Session::singleton()->setStatus(ts('This contact was deleted during a merge operation. The contact it was merged into cannot be found and may have been deleted.'));

…ccess a merged contact and the contact that it was merged into has been permanently deleted

Move exception capturing into the page layer and extend unit test to cover page function

Update status message as per Mikeý's comment
@seamuslee001
Copy link
Contributor Author

Thanks Mikey that works for me have updated now @eileenmcnaughton @MikeyMJCO

@eileenmcnaughton eileenmcnaughton merged commit ee028d9 into civicrm:master Sep 29, 2020
@eileenmcnaughton
Copy link
Contributor

thanks @seamuslee001 @MikeyMJCO

@eileenmcnaughton eileenmcnaughton deleted the dev_core_1838 branch September 29, 2020 19:17
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