From 5e68fa06f6069a95e16b449805ace2be08ab27c0 Mon Sep 17 00:00:00 2001 From: eileen Date: Thu, 4 Feb 2021 17:50:29 +1300 Subject: [PATCH] [REF] Complete order Unset contribution once we have finished with it. This patch does very little but it takes a bit of searching to check the handful of places that call completeOrder and check that none of them use the contribution object after this function call. With this merged it will be possible to cleanup the references to the contribution in the repeattransaction code safe in the knowledge that the object is not needed after that function (or within it from my reading). It seems likely we can switch to passing in contributionID rather than the whole object. --- CRM/Contribute/BAO/Contribution.php | 3 +-- CRM/Core/Payment/AuthorizeNetIPN.php | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/CRM/Contribute/BAO/Contribution.php b/CRM/Contribute/BAO/Contribution.php index 890183b536..d6cdb7f1c7 100644 --- a/CRM/Contribute/BAO/Contribution.php +++ b/CRM/Contribute/BAO/Contribution.php @@ -4279,6 +4279,7 @@ INNER JOIN civicrm_activity ON civicrm_activity_contact.activity_id = civicrm_ac $contributionResult = self::repeatTransaction($contribution, $input, $contributionParams); $contributionID = (int) $contribution->id; + unset($contribution); if ($input['component'] == 'contribute') { if ($contributionParams['contribution_status_id'] === $completedContributionStatusID) { @@ -4303,8 +4304,6 @@ INNER JOIN civicrm_activity ON civicrm_activity_contact.activity_id = civicrm_ac $contributionResult = civicrm_api3('Contribution', 'create', $contributionParams); } - $contribution->contribution_status_id = $contributionParams['contribution_status_id']; - $transaction->commit(); \Civi::log()->info("Contribution {$contributionParams['id']} updated successfully"); diff --git a/CRM/Core/Payment/AuthorizeNetIPN.php b/CRM/Core/Payment/AuthorizeNetIPN.php index cefee59c19..2d6d571349 100644 --- a/CRM/Core/Payment/AuthorizeNetIPN.php +++ b/CRM/Core/Payment/AuthorizeNetIPN.php @@ -62,7 +62,7 @@ class CRM_Core_Payment_AuthorizeNetIPN extends CRM_Core_Payment_BaseIPN { // Check if the contribution exists // make sure contribution exists and is valid $contribution = new CRM_Contribute_BAO_Contribution(); - $contribution->id = $ids['contribution']; + $contribution->id = $contributionID = $ids['contribution']; if (!$contribution->find(TRUE)) { throw new CRM_Core_Exception('Failure: Could not find contribution record for ' . (int) $contribution->id, NULL, ['context' => "Could not find contribution record: {$contribution->id} in IPN request: " . print_r($input, TRUE)]); } @@ -92,7 +92,7 @@ class CRM_Core_Payment_AuthorizeNetIPN extends CRM_Core_Payment_BaseIPN { $contributionRecur->contact_id, $ids['contributionPage'], $contributionRecur, - (bool) $this->getMembershipID($contribution->id, $contributionRecur->id) + (bool) $this->getMembershipID($contributionID, $contributionRecur->id) ); } -- 2.25.1