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#3028 - For invalid greetings, return '' instead of failing #22650

Merged
merged 1 commit into from
Jan 28, 2022

Conversation

totten
Copy link
Member

@totten totten commented Jan 28, 2022

Overview

Fix crash when re-generating greetings for invalid data.

As mentioned in the ticket, I was able to reproduce by hacking at the SQL:

update civicrm_contact set postal_greeting_id = 999 where id = 200;

I think a plausible, organic scenario for this would be:

  1. Add a new postal_greeting (Ex: INSERT INTO civicrm_option_value ... ("My Greeting",123,...))
  2. Update a Contact to use the new greeting. (Ex: Set postal_greeting_id=123)
  3. Delete the postal_greeting. (Ex: The contact now has an invalid postal_greeting_id==123.)
  4. Perform some action that requires recalculating the greeting. (Ex: Merge the contact with another contact.)

See: https://lab.civicrm.org/dev/core/-/issues/3028

Before

Recalculating the greeting leads to a type error:

TypeError: Return value of CRM_Contact_BAO_Contact::getTemplateForGreeting() 
must be of the type string, null returned in CRM_Contact_BAO_Contact::getTemplateForGreeting()
(line 3509 of /var/www/vhosts/xyz/webroot/sites/all/modules/civicrm/CRM/Contact/BAO/Contact.php).

After

No crash. The greeting value is blank (which is a common form omission, if you look at other paths in the context).

@civibot
Copy link

civibot bot commented Jan 28, 2022

(Standard links)

@civibot civibot bot added the master label Jan 28, 2022
@totten totten changed the base branch from master to 5.46 January 28, 2022 06:12
@civibot civibot bot added 5.46 and removed master labels Jan 28, 2022
@totten
Copy link
Member Author

totten commented Jan 28, 2022

This is actually @eileenmcnaughton's patch which I had tested last night. Adding "merge on pass" based on last night's testing.

@demeritcowboy demeritcowboy merged commit b406dcb into civicrm:5.46 Jan 28, 2022
@totten totten deleted the 5.46-greeting branch January 28, 2022 22:40
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