From 557e8899b776dcdb770d6b7c69f6550fcbb3179a Mon Sep 17 00:00:00 2001 From: eileenmcnaughton Date: Thu, 26 Nov 2015 20:54:15 +0000 Subject: [PATCH] CRM-17519 further leaky var fix on useForMember (this leakage was blocking fixing CRM-17539 - it might be 'in the wild' like the other leakage - but the impact of it if that the receipt looks slightly different & it would not be noticeable (potentially) --- CRM/Contribute/BAO/Contribution.php | 2 +- CRM/Contribute/BAO/ContributionPage.php | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CRM/Contribute/BAO/Contribution.php b/CRM/Contribute/BAO/Contribution.php index 5798aa52d2..3dbe993ab0 100644 --- a/CRM/Contribute/BAO/Contribution.php +++ b/CRM/Contribute/BAO/Contribution.php @@ -2638,7 +2638,7 @@ INNER JOIN civicrm_activity ON civicrm_activity_contact.activity_id = civicrm_ac $template->assign('last_name', $this->_relatedObjects['contact']->last_name); $template->assign('displayName', $this->_relatedObjects['contact']->display_name); if (!empty($values['lineItem']) && !empty($this->_relatedObjects['membership'])) { - $template->assign('useForMember', TRUE); + $values['useForMember'] = TRUE; } //assign honor information to receipt message $softRecord = CRM_Contribute_BAO_ContributionSoft::getSoftContribution($this->id); diff --git a/CRM/Contribute/BAO/ContributionPage.php b/CRM/Contribute/BAO/ContributionPage.php index 092c6a2ed7..1656bc485a 100644 --- a/CRM/Contribute/BAO/ContributionPage.php +++ b/CRM/Contribute/BAO/ContributionPage.php @@ -157,7 +157,8 @@ class CRM_Contribute_BAO_ContributionPage extends CRM_Contribute_DAO_Contributio // We are trying to fight the good fight against leaky variables (CRM-17519) so let's get really explicit // about ensuring the variables we want for the template are defined. // @todo add to this until all tpl params are explicit in this function and not waltzing around the codebase. - $valuesRequiredForTemplate = array('customPre', 'customPost', 'customPre_grouptitle', 'customPost_grouptitle'); + $valuesRequiredForTemplate = array('customPre', 'customPost', 'customPre_grouptitle', 'customPost_grouptitle', + 'useForMember'); foreach ($valuesRequiredForTemplate as $valueRequiredForTemplate) { if (!isset($values[$valueRequiredForTemplate])) { $values[$valueRequiredForTemplate] = NULL; @@ -347,7 +348,8 @@ class CRM_Contribute_BAO_ContributionPage extends CRM_Contribute_DAO_Contributio $title = isset($values['title']) ? $values['title'] : CRM_Contribute_PseudoConstant::contributionPage($values['contribution_page_id']); - // set email in the template here + // Set email variables explicitly to avoid leaky smarty variables. + // All of these will be assigned to the template, replacing any that might be assigned elsewhere. $tplParams = array( 'email' => $email, 'receiptFromEmail' => CRM_Utils_Array::value('receipt_from_email', $values), @@ -366,6 +368,7 @@ class CRM_Contribute_BAO_ContributionPage extends CRM_Contribute_DAO_Contributio 'customPre_grouptitle' => $values['customPre_grouptitle'], 'customPost' => $values['customPost'], 'customPost_grouptitle' => $values['customPost_grouptitle'], + 'useForMember' => $values['useForMember'], ); if ($contributionTypeId = CRM_Utils_Array::value('financial_type_id', $values)) { -- 2.25.1