From: eileen Date: Tue, 25 Aug 2020 20:48:12 +0000 (+1200) Subject: Remove last pass-by-reference in completeOrder signature X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=c74976533ef772af916059fd1d8f7a2365b06ac0;p=civicrm-core.git Remove last pass-by-reference in completeOrder signature ids is now only referred to once in the function & never altered. I have assigned that value to a param & unset ids after that to make that clear --- diff --git a/CRM/Contribute/BAO/Contribution.php b/CRM/Contribute/BAO/Contribution.php index a74d99bc57..3494b5ee3d 100644 --- a/CRM/Contribute/BAO/Contribution.php +++ b/CRM/Contribute/BAO/Contribution.php @@ -4452,9 +4452,15 @@ INNER JOIN civicrm_activity ON civicrm_activity_contact.activity_id = civicrm_ac * @throws \CRM_Core_Exception * @throws \CiviCRM_API3_Exception */ - public static function completeOrder($input, &$ids, $objects, $isPostPaymentCreate = FALSE) { + public static function completeOrder($input, $ids, $objects, $isPostPaymentCreate = FALSE) { $transaction = new CRM_Core_Transaction(); $contribution = $objects['contribution']; + // @todo see if we even need this - it's used further down to create an activity + // but the BAO layer should create that - we just need to add a test to cover it & can + // maybe remove $ids altogether. + $contributionContactID = $ids['related_contact'] ?? NULL; + // Unset ids just to make it clear it's not used again. + unset($ids); // The previous details are used when calculating line items so keep it before any code that 'does something' if (!empty($contribution->id)) { $input['prevContribution'] = CRM_Contribute_BAO_Contribution::getValues(['id' => $contribution->id]); @@ -4565,9 +4571,9 @@ INNER JOIN civicrm_activity ON civicrm_activity_contact.activity_id = civicrm_ac if ($input['component'] == 'contribute') { //CRM-4027 $targetContactID = NULL; - if (!empty($ids['related_contact'])) { + if ($contributionContactID) { $targetContactID = $contribution->contact_id; - $contribution->contact_id = $ids['related_contact']; + $contribution->contact_id = $contributionContactID; } CRM_Activity_BAO_Activity::addActivity($contribution, NULL, $targetContactID); } diff --git a/CRM/Core/Payment/BaseIPN.php b/CRM/Core/Payment/BaseIPN.php index 930baec016..e4312a5fd7 100644 --- a/CRM/Core/Payment/BaseIPN.php +++ b/CRM/Core/Payment/BaseIPN.php @@ -467,7 +467,7 @@ class CRM_Core_Payment_BaseIPN { * @throws \CRM_Core_Exception * @throws \CiviCRM_API3_Exception */ - public function completeTransaction(&$input, &$ids, &$objects) { + public function completeTransaction($input, $ids, $objects) { CRM_Contribute_BAO_Contribution::completeOrder($input, $ids, $objects); }