Remove call to getTokenDetails
authorEileen McNaughton <emcnaughton@wikimedia.org>
Wed, 3 Nov 2021 21:27:16 +0000 (10:27 +1300)
committerEileen McNaughton <emcnaughton@wikimedia.org>
Thu, 4 Nov 2021 02:08:15 +0000 (15:08 +1300)
This is tested vi CRM_Event_Form_Task_BatchTest::testSubmitCancel

CRM/Event/BAO/Participant.php
CRM/Utils/Token.php

index d72012f5c1fb9cfd14a82aa29cde000ea84b3ef4..618927d8c5688fc97635f649b7a2f4f6c14db82b 100644 (file)
@@ -1236,15 +1236,7 @@ UPDATE  civicrm_participant
 
     //get all required contacts detail.
     if (!empty($contactIds)) {
-      // get the contact details.
-      list($currentContactDetails) = CRM_Utils_Token::getTokenDetails($contactIds, NULL,
-        FALSE, FALSE, NULL,
-        [],
-        'CRM_Event_BAO_Participant'
-      );
-      foreach ($currentContactDetails as $contactId => $contactValues) {
-        $contactDetails[$contactId] = $contactValues;
-      }
+      $contactDetails = civicrm_api3('Contact', 'get', ['id' => ['IN' => $contactIds, 'return' => 'display_name']])['values'];
     }
 
     //get all required events detail.
@@ -1312,7 +1304,7 @@ UPDATE  civicrm_participant
             $mail = self::sendTransitionParticipantMail($additionalId,
               $participantDetails[$additionalId],
               $eventDetails[$participantDetails[$additionalId]['event_id']],
-              $contactDetails[$participantDetails[$additionalId]['contact_id']],
+              NULL,
               $emailType
             );
 
@@ -1331,7 +1323,7 @@ UPDATE  civicrm_participant
         $mail = self::sendTransitionParticipantMail($participantId,
           $participantValues,
           $eventDetails[$participantValues['event_id']],
-          $contactDetails[$participantValues['contact_id']],
+          NULL,
           $emailType
         );
 
index bd927721ba9d7acdbb11ac1dcec0cb304695b5b0..1ab9cc2dbf0a21dbb3c8447171ade5b2286174e3 100644 (file)
@@ -1134,6 +1134,8 @@ class CRM_Utils_Token {
   }
 
   /**
+   * Do not use this function.
+   *
    * Gives required details of contacts in an indexed array format so we
    * can iterate in a nice loop and do token evaluation
    *
@@ -1152,6 +1154,8 @@ class CRM_Utils_Token {
    * @param int|null $jobID
    *   The mailing list jobID - this is a legacy param.
    *
+   * @deprecated
+   *
    * @return array - e.g [[1 => ['first_name' => 'bob'...], 34 => ['first_name' => 'fred'...]]]
    */
   public static function getTokenDetails(
@@ -1164,7 +1168,6 @@ class CRM_Utils_Token {
     $className = NULL,
     $jobID = NULL
   ) {
-
     $params = [];
     foreach ($contactIDs as $contactID) {
       $params[] = [