From 4c820cf94553187b0d83201da180bd2d59ecd861 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Fri, 15 Oct 2021 00:42:28 -0700 Subject: [PATCH] replaceGreetingTokens - Be more forgiving about $contactDetails This should fix a failure in `TokenConsistencyTest`. Setting a breakpoint and monitoring `$contactDetails`, it appears that the data would come in multiple formats. (Sometimes as a nested array; sometimes as a flatter array.) This makes it work with both cases. --- CRM/Utils/Token.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/CRM/Utils/Token.php b/CRM/Utils/Token.php index 2f7db99438..53cebfafc0 100644 --- a/CRM/Utils/Token.php +++ b/CRM/Utils/Token.php @@ -1337,10 +1337,7 @@ class CRM_Utils_Token { $greetingTokens = self::getTokens($tokenString); $context = $contactId ? ['contactId' => $contactId] : []; if ($contactDetails) { - foreach ($contactDetails[0] as $contact) { - // Only 1 - the loop is because we may not know the id. - $context['contact'] = $contact; - } + $context['contact'] = isset($contactDetails[0]) ? reset($contactDetails[0]) : $contactDetails; } $tokenProcessor = new TokenProcessor(\Civi::dispatcher(), [ 'smarty' => FALSE, -- 2.25.1