From 31e251e69d100664afd8487e133b58959d4aecc0 Mon Sep 17 00:00:00 2001 From: eileen Date: Wed, 29 Jul 2020 09:58:18 +1200 Subject: [PATCH] [REF] Remove pass-by-reference & always empty param Once https://github.com/civicrm/civicrm-core/pull/17982 is merged there are only 2 places that call this function. In both places 1) they instantiate an empty values array just to pass in 2) we can see they don't use input or ids afterwards, so they don't need to be passed by reference --- CRM/Contribute/BAO/Contribution.php | 5 ++--- CRM/Contribute/Form/Task/PDF.php | 4 +--- api/v3/Contribution.php | 4 ++-- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/CRM/Contribute/BAO/Contribution.php b/CRM/Contribute/BAO/Contribution.php index 75afd52626f1..5398ff3835a6 100644 --- a/CRM/Contribute/BAO/Contribution.php +++ b/CRM/Contribute/BAO/Contribution.php @@ -4609,9 +4609,8 @@ public static function completeOrder($input, &$ids, $objects, $transaction = NUL * @throws \CiviCRM_API3_Exception * @throws \Exception */ - public static function sendMail(&$input, &$ids, $contributionID, &$values, - $returnMessageText = FALSE) { - + public static function sendMail($input, $ids, $contributionID, $returnMessageText = FALSE) { + $values = []; $contribution = new CRM_Contribute_BAO_Contribution(); $contribution->id = $contributionID; if (!$contribution->find(TRUE)) { diff --git a/CRM/Contribute/Form/Task/PDF.php b/CRM/Contribute/Form/Task/PDF.php index 76dac1989fb1..b9d67ae41f65 100644 --- a/CRM/Contribute/Form/Task/PDF.php +++ b/CRM/Contribute/Form/Task/PDF.php @@ -184,7 +184,6 @@ public function postProcess() { // CRM_Contribute_BAO_Contribution::composeMessageArray expects mysql formatted date $objects['contribution']->receive_date = CRM_Utils_Date::isoToMysql($objects['contribution']->receive_date); - $values = []; if (isset($params['from_email_address']) && !$elements['createPdf']) { // If a logged in user from email is used rather than a domain wide from email address // the from_email_address params key will be numerical and we need to convert it to be @@ -196,8 +195,7 @@ public function postProcess() { $input['receipt_from_name'] = str_replace('"', '', $fromDetails[0]); } - $mail = CRM_Contribute_BAO_Contribution::sendMail($input, $ids, $objects['contribution']->id, $values, - $elements['createPdf']); + $mail = CRM_Contribute_BAO_Contribution::sendMail($input, $ids, $objects['contribution']->id, $elements['createPdf']); if ($mail['html']) { $message[] = $mail['html']; diff --git a/api/v3/Contribution.php b/api/v3/Contribution.php index bbe016918144..0c80fb994445 100644 --- a/api/v3/Contribution.php +++ b/api/v3/Contribution.php @@ -393,7 +393,7 @@ function _civicrm_api3_contribute_format_params($params, &$values) { * @throws Exception */ function civicrm_api3_contribution_sendconfirmation($params) { - $ids = $values = []; + $ids = []; $allowedParams = [ 'receipt_from_email', 'receipt_from_name', @@ -405,7 +405,7 @@ function civicrm_api3_contribution_sendconfirmation($params) { ]; $input = array_intersect_key($params, array_flip($allowedParams)); $input['is_email_receipt'] = TRUE; - CRM_Contribute_BAO_Contribution::sendMail($input, $ids, $params['id'], $values); + CRM_Contribute_BAO_Contribution::sendMail($input, $ids, $params['id']); } /**