From 2df49c859d77fcd2ee073fe14f39f2b4c792ebb9 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Tue, 27 Jul 2021 20:51:10 +1200 Subject: [PATCH] Cast to float when setting overrideTotalAmount This is a regression in master whereby submitting a new contribution and leaving total_amount empty causes a fatal before it can get to the validation error - back office contribution form --- CRM/Batch/Form/Entry.php | 2 +- CRM/Contribute/Form/Contribution.php | 2 +- CRM/Contribute/Form/Contribution/Confirm.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CRM/Batch/Form/Entry.php b/CRM/Batch/Form/Entry.php index 3e0fdd187e..79971447be 100644 --- a/CRM/Batch/Form/Entry.php +++ b/CRM/Batch/Form/Entry.php @@ -808,7 +808,7 @@ class CRM_Batch_Form_Entry extends CRM_Core_Form { $order = new CRM_Financial_BAO_Order(); // We use the override total amount because we are dealing with a // possibly tax_inclusive total, which is assumed for the override total. - $order->setOverrideTotalAmount($value['total_amount']); + $order->setOverrideTotalAmount((float) $value['total_amount']); $order->setLineItem([ 'membership_type_id' => $value['membership_type_id'], 'financial_type_id' => $value['financial_type_id'], diff --git a/CRM/Contribute/Form/Contribution.php b/CRM/Contribute/Form/Contribution.php index ae1f4da7e2..fc87109c57 100644 --- a/CRM/Contribute/Form/Contribution.php +++ b/CRM/Contribute/Form/Contribution.php @@ -921,7 +921,7 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP $order = new CRM_Financial_BAO_Order(); $order->setPriceSelectionFromUnfilteredInput($fields); if (isset($fields['total_amount'])) { - $order->setOverrideTotalAmount($fields['total_amount']); + $order->setOverrideTotalAmount((float) $fields['total_amount']); } $lineItems = $order->getLineItems(); try { diff --git a/CRM/Contribute/Form/Contribution/Confirm.php b/CRM/Contribute/Form/Contribution/Confirm.php index 8d771e4026..559bc0675f 100644 --- a/CRM/Contribute/Form/Contribution/Confirm.php +++ b/CRM/Contribute/Form/Contribution/Confirm.php @@ -2000,7 +2000,7 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr $order->setPriceSelectionFromUnfilteredInput($params); if (isset($params['amount']) && !CRM_Contribute_BAO_ContributionPage::getIsMembershipPayment($form->_id)) { // @todo deprecate receiving amount, calculate on the form. - $order->setOverrideTotalAmount($params['amount']); + $order->setOverrideTotalAmount((float) $params['amount']); } $amount = $order->getTotalAmount(); if ($form->_separateMembershipPayment) { -- 2.25.1