dev/core#2748 Remove unused token assigns
authorEileen McNaughton <emcnaughton@wikimedia.org>
Sat, 7 Aug 2021 07:18:30 +0000 (19:18 +1200)
committerEileen McNaughton <emcnaughton@wikimedia.org>
Thu, 9 Sep 2021 00:21:36 +0000 (12:21 +1200)
CRM/Contribute/BAO/Contribution.php
CRM/Upgrade/Incremental/php/FiveFortyThree.php
CRM/Utils/Token.php
tests/phpunit/api/v3/ContributionTest.php
tests/templates/message_templates/contribution_online_receipt_html.tpl

index cc44a430a26637b8adbcf71afb794b9ed0b24445..9c9e22e03564b09bfa116b2e59d058e10f49ba47 100644 (file)
@@ -2983,15 +2983,8 @@ INNER JOIN civicrm_activity ON civicrm_activity_contact.activity_id = civicrm_ac
     // and this function should assign them (assigning null if not set).
     // the way the pcpParams & honor Params section works is a baby-step towards this.
     $template = CRM_Core_Smarty::singleton();
-    $template->assign('first_name', $this->_relatedObjects['contact']->first_name);
-    $template->assign('last_name', $this->_relatedObjects['contact']->last_name);
-    $template->assign('displayName', $this->_relatedObjects['contact']->display_name);
     $template->assign('billingName', $values['billingName']);
 
-    // For some unit tests contribution cannot contain paymentProcessor information
-    $billingMode = empty($this->_relatedObjects['paymentProcessor']) ? CRM_Core_Payment::BILLING_MODE_NOTIFY : $this->_relatedObjects['paymentProcessor']['billing_mode'];
-    $template->assign('contributeMode', CRM_Core_SelectValues::contributeMode()[$billingMode] ?? NULL);
-
     //assign honor information to receipt message
     $softRecord = CRM_Contribute_BAO_ContributionSoft::getSoftContribution($this->id);
 
index a3b8c9c30c80e8c8004f6d8454fb20bfacabce56..413b61e62bb5a6ed4404360582c5fc5f759c39b8 100644 (file)
@@ -60,9 +60,19 @@ class CRM_Upgrade_Incremental_php_FiveFortyThree extends CRM_Upgrade_Incremental
    *
    * @param string $rev
    */
-  public function upgrade_5_43_alpha1($rev) {
+  public function upgrade_5_43_alpha1(string $rev): void {
     $this->addTask(ts('Upgrade DB to %1: SQL', [1 => $rev]), 'runSql', $rev);
     $this->addTask('Fix DB Collation if needed on the relatonship cache table', 'fixRelationshipCacheTableCollation');
+
+    $this->addTask('Replace legacy displayName smarty token in Online contribution workflow template',
+      'updateMessageToken', 'contribution_online_receipt', '$displayName', 'contact.display_name', $rev
+    );
+    $this->addTask('Replace legacy first_name smarty token in Online contribution workflow template',
+      'updateMessageToken', 'contribution_online_receipt', '$first_name', 'contact.first_name', $rev
+    );
+    $this->addTask('Replace legacy last_name smarty token in Online contribution workflow template',
+      'updateMessageToken', 'contribution_online_receipt', '$last_name', 'contact.last_name', $rev
+    );
   }
 
   public static function fixRelationshipCacheTableCollation():bool {
index 709f3671e8f7c839cbb99ac3ca1e7124aeda9807..ec27a8ed1af521f5d9d30b8689f702216028690e 100644 (file)
@@ -1952,6 +1952,12 @@ class CRM_Utils_Token {
         'contribution_invoice_receipt' => [
           '$display_name' => 'contact.display_name',
         ],
+        'contribution_online_receipt' => [
+          '$contributeMode' => 'no longer available / relevant',
+          '$first_name' => 'contact.first_name',
+          '$last_name' => 'contact.last_name',
+          '$displayName' => 'contact.display_name',
+        ],
       ],
     ];
   }
index 30d18578553c5e6b3c4b5972381fcd2d6f4cee8b..4d9dc491cf355ebd76e81fee93edfa23e932be63 100644 (file)
@@ -2072,9 +2072,7 @@ class api_v3_ContributionTest extends CiviUnitTestCase {
       'currency:::USD',
       'receive_date:::' . date('Ymd', strtotime($contribution['receive_date'])),
       "receipt_date:::\n",
-      'contributeMode:::notify',
       'title:::Contribution',
-      'displayName:::Mr. Anthony Anderson II',
       'contributionStatus:::Completed',
     ]);
     $mut->stop();
@@ -2112,9 +2110,7 @@ class api_v3_ContributionTest extends CiviUnitTestCase {
       'currency:::EUR',
       'receive_date:::' . date('Ymd', strtotime($contribution['receive_date'])),
       "receipt_date:::\n",
-      'contributeMode:::notify',
       'title:::Contribution',
-      'displayName:::Mr. Anthony Anderson II',
       'contributionStatus:::Completed',
     ]);
     $mut->stop();
@@ -2150,7 +2146,6 @@ class api_v3_ContributionTest extends CiviUnitTestCase {
       'is_pay_later:::1',
       'email:::anthony_anderson@civicrm.org',
       'pay_later_receipt:::This is a pay later receipt',
-      'displayName:::Mr. Anthony Anderson II',
       'contributionPageId:::' . $contributionPageID,
       'title:::Test Contribution Page',
       'amount:::100',
@@ -3185,9 +3180,7 @@ class api_v3_ContributionTest extends CiviUnitTestCase {
       'currency:::USD',
       'receive_date:::' . date('Ymd', strtotime($receive_date)),
       'receipt_date:::' . date('Ymd'),
-      'contributeMode:::notify',
       'title:::Contribution',
-      'displayName:::Mr. Anthony Anderson II',
       'trxn_id:::kazam',
       'contactID:::' . $this->_params['contact_id'],
       'contributionID:::' . $contribution['id'],
index c9cdcdb8201a05be0853129905c068577212b0fe..8f98967aec4d2168baff55f513e212a39d4f9a71 100644 (file)
@@ -9,7 +9,6 @@
   receipt_text:::{$receipt_text}
   {/if}
   is_pay_later:::{$is_pay_later}
-  displayName:::{$displayName}
   financialTypeId:::{$financialTypeId}
   financialTypeName:::{$financialTypeName}
   contactID:::{$contactID}
@@ -52,9 +51,6 @@
   {if isset($is_recur)}
   is_recur:::{$is_recur}
   {/if}
-  {if isset($contributeMode)}
-  contributeMode:::{$contributeMode}
-  {/if}
   {if isset($trxn_id)}
   trxn_id:::{$trxn_id}
   {/if}