dev/core#2817 remove call to getTokenDetails
authorEileen McNaughton <emcnaughton@wikimedia.org>
Tue, 14 Sep 2021 15:09:49 +0000 (03:09 +1200)
committerEileen McNaughton <emcnaughton@wikimedia.org>
Tue, 14 Sep 2021 18:59:31 +0000 (06:59 +1200)
Removes the call to getTokenDetails as discussed on
https://github.com/civicrm/civicrm-core/pull/21445

As discussed on that PR & related gitlabs I
created an extension to try to allow people to have
this functionality transitionally if they needed
(based on copying code from 5.41 over) - but
per the readme https://github.com/eileenmcnaughton/legacytokenhelper/blob/master/README.md
the issues I found (under 'known issues') were enough
to make me conclude no-one would actually
want to install the extension to restore pre-5.43
functionality

CRM/Contact/Form/Task/PDFLetterCommon.php

index 6ca9dd00ad161c7c412f000f5e0cba0460742e96..2c1e432fd7519bd25b3b1f01f29a797df3b1b279 100644 (file)
@@ -117,8 +117,6 @@ class CRM_Contact_Form_Task_PDFLetterCommon extends CRM_Core_Form_Task_PDFLetter
   public static function postProcess(&$form): void {
     $formValues = $form->controller->exportValues($form->getName());
     [$formValues, $categories, $html_message, $messageToken, $returnProperties] = self::processMessageTemplate($formValues);
-    $skipOnHold = $form->skipOnHold ?? FALSE;
-    $skipDeceased = $form->skipDeceased ?? TRUE;
     $html = $activityIds = [];
 
     // CRM-16725 Skip creation of activities if user is previewing their PDF letter(s)
@@ -131,32 +129,14 @@ class CRM_Contact_Form_Task_PDFLetterCommon extends CRM_Core_Form_Task_PDFLetter
     }
 
     foreach ($form->_contactIds as $item => $contactId) {
-      $caseId = NULL;
-      $params = ['contact_id' => $contactId];
-
       $caseId = $form->getVar('_caseId');
       if (empty($caseId) && !empty($form->_caseIds[$item])) {
         $caseId = $form->_caseIds[$item];
       }
 
-      [$contact] = CRM_Utils_Token::getTokenDetails($params,
-        $returnProperties,
-        $skipOnHold,
-        $skipDeceased,
-        NULL,
-        $messageToken,
-        'CRM_Contact_Form_Task_PDFLetterCommon'
-      );
-
-      if (civicrm_error($contact)) {
-        $notSent[] = $contactId;
-        continue;
-      }
-
       $tokenHtml = CRM_Core_BAO_MessageTemplate::renderTemplate([
         'contactId' => $contactId,
         'messageTemplate' => ['msg_html' => $html_message],
-        'tplParams' => ['contact' => $contact],
         'tokenContext' => $caseId ? ['caseId' => $caseId] : [],
         'disableSmarty' => (!defined('CIVICRM_MAIL_SMARTY') || !CIVICRM_MAIL_SMARTY),
       ])['html'];