From c69dce920cf125efef301190d3c0c86bf70f3ff2 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Fri, 18 Mar 2022 18:48:32 +1300 Subject: [PATCH] Ensure some variables are assigned to the template This should address some enotices that are blocking extending test grumpiness It's not my preferred fix but getting to that is a bit chicken & egg.... --- CRM/Contribute/BAO/Contribution.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/CRM/Contribute/BAO/Contribution.php b/CRM/Contribute/BAO/Contribution.php index 83cd097c9d..d32c9aed63 100644 --- a/CRM/Contribute/BAO/Contribution.php +++ b/CRM/Contribute/BAO/Contribution.php @@ -2812,6 +2812,11 @@ INNER JOIN civicrm_activity ON civicrm_activity_contact.activity_id = civicrm_ac // the way the pcpParams & honor Params section works is a baby-step towards this. $template = CRM_Core_Smarty::singleton(); $template->assign('billingName', $values['billingName']); + // It is unclear if onBehalfProfile is still assigned & where - but + // it is still referred to in templates so avoid an e-notice. + // Credit card type is assigned on the form layer but should also be + // assigned when payment.create is called.... + $template->ensureVariablesAreAssigned(['onBehalfProfile', 'credit_card_type']); //assign honor information to receipt message $softRecord = CRM_Contribute_BAO_ContributionSoft::getSoftContribution($this->id); @@ -2842,10 +2847,10 @@ INNER JOIN civicrm_activity ON civicrm_activity_contact.activity_id = civicrm_ac 'Amount' => CRM_Utils_Money::format($softCredit['amount'], $softCredit['currency']), ]; } - $template->assign('softCreditTypes', $softCreditTypes); - $template->assign('softCredits', $softCredits); } } + $template->assign('softCreditTypes', $softCreditTypes ?? NULL); + $template->assign('softCredits', $softCredits ?? NULL); $dao = new CRM_Contribute_DAO_ContributionProduct(); $dao->contribution_id = $this->id; @@ -2861,6 +2866,9 @@ INNER JOIN civicrm_activity ON civicrm_activity_contact.activity_id = civicrm_ac $template->assign('price', $productDAO->price); $template->assign('sku', $productDAO->sku); } + else { + $template->assign('selectPremium', FALSE); + } $template->assign('title', $values['title'] ?? NULL); $values['amount'] = CRM_Utils_Array::value('total_amount', $input, (CRM_Utils_Array::value('amount', $input)), NULL); if (!$values['amount'] && isset($this->total_amount)) { @@ -2875,7 +2883,7 @@ INNER JOIN civicrm_activity ON civicrm_activity_contact.activity_id = civicrm_ac 'title' => NULL, ]; - if (strtolower($this->_component) == 'contribute') { + if (strtolower($this->_component) === 'contribute') { //PCP Info $softDAO = new CRM_Contribute_DAO_ContributionSoft(); $softDAO->contribution_id = $this->id; @@ -2918,7 +2926,7 @@ INNER JOIN civicrm_activity ON civicrm_activity_contact.activity_id = civicrm_ac if (!empty($values['softContributions'])) { $template->assign('softContributions', $values['softContributions']); } - if ($this->_component == 'event') { + if ($this->_component === 'event') { $template->assign('title', $values['event']['title']); $participantRoles = CRM_Event_PseudoConstant::participantRole(); $viewRoles = []; -- 2.25.1