From 58b8a3df198864ff473046b6054d7f95640ac192 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Sun, 23 Jan 2022 19:14:09 -0500 Subject: [PATCH] Contact Greetings - Fix assumption about empty values The function `ensureGreetingParamsAreSet` was assuming that the string 'null' means NULL but an empty string was "no value given". In reality, an empty string can also signify NULL, and only a true NULL or unset value means "no value given". --- CRM/Contact/BAO/Contact.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CRM/Contact/BAO/Contact.php b/CRM/Contact/BAO/Contact.php index 725859fcd5..026bbdbfba 100644 --- a/CRM/Contact/BAO/Contact.php +++ b/CRM/Contact/BAO/Contact.php @@ -503,6 +503,10 @@ class CRM_Contact_BAO_Contact extends CRM_Contact_DAO_Contact implements Civi\Te $missingGreetingParams = []; foreach ($allGreetingParams as $greetingIndex => $greetingParam) { + // An empty string means NULL + if (($params[$greetingParam] ?? NULL) === '') { + $params[$greetingParam] = 'null'; + } if (empty($params[$greetingParam])) { $missingGreetingParams[$greetingIndex] = $greetingParam; } -- 2.25.1