From 4d385723bb75b15575799efc51f419081fa8bc44 Mon Sep 17 00:00:00 2001 From: eileen Date: Fri, 2 Oct 2020 09:17:45 +1300 Subject: [PATCH] dev/core#2079 do not return never-used, query-wasting variable The second value from apiQuery is calculated using an extraneous uncached query. This function is the only function that calls that function AND puts that value into a variable. This change clarfies that this function does not require thhe variable --- CRM/Utils/Token.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/CRM/Utils/Token.php b/CRM/Utils/Token.php index 850a2516ac..6cc3365cae 100644 --- a/CRM/Utils/Token.php +++ b/CRM/Utils/Token.php @@ -1160,11 +1160,11 @@ class CRM_Utils_Token { * Extra params. * @param array $tokens * The list of tokens we've extracted from the content. - * @param null $className - * @param int $jobID + * @param string|null $className + * @param int|null $jobID * The mailing list jobID - this is a legacy param. * - * @return array + * @return array - e.g [[1 => ['first_name' => 'bob'...], 34 => ['first_name' => 'fred'...]]] */ public static function getTokenDetails( $contactIDs, @@ -1227,8 +1227,7 @@ class CRM_Utils_Token { } } - $details = CRM_Contact_BAO_Query::apiQuery($params, $returnProperties, NULL, NULL, 0, count($contactIDs), TRUE, FALSE, TRUE, CRM_Contact_BAO_Query::MODE_CONTACTS, NULL, TRUE); - $contactDetails = &$details[0]; + [$contactDetails] = CRM_Contact_BAO_Query::apiQuery($params, $returnProperties, NULL, NULL, 0, count($contactIDs), TRUE, FALSE, TRUE, CRM_Contact_BAO_Query::MODE_CONTACTS, NULL, TRUE); foreach ($contactIDs as $contactID) { if (array_key_exists($contactID, $contactDetails)) { @@ -1270,7 +1269,7 @@ class CRM_Utils_Token { $tokens, $className ); - return $details; + return [$contactDetails]; } /** -- 2.25.1