Contact Greetings - Fix assumption about empty values
authorColeman Watts <coleman@civicrm.org>
Mon, 24 Jan 2022 00:14:09 +0000 (19:14 -0500)
committerColeman Watts <coleman@civicrm.org>
Mon, 24 Jan 2022 00:14:09 +0000 (19:14 -0500)
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

index 725859fcd547b0c58ae96492d309881d1a6bba94..026bbdbfba4af6981c81fbc0681f960110536ac7 100644 (file)
@@ -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;
       }