From 863592c31644c445663bb8ad08b47aaed91ee24c Mon Sep 17 00:00:00 2001 From: eileen Date: Sat, 5 Sep 2020 15:52:12 +1200 Subject: [PATCH] Simply loading of related objects in transition components This alters transitionComponents to bypass validateData to load the related objects Stepping through validateData it's clear that validate data 1) loads the contribution - this is now in transitionComponents 2) loads the contact - that is not specifically necessary as it is not used in transitionComponents 3) does some validation that relates to the IPNyness of BaseIPN but not to an internally called function 4) calls 'loadObjects' LoadObjects does some error handling, sets the processorID if passed in, which it isn't and then calls contribution->loadRelatedObjects( ) - we now do that last call directly in-function OrderTest::testCancelWithParticipant passes directly through this code --- CRM/Contribute/BAO/Contribution.php | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/CRM/Contribute/BAO/Contribution.php b/CRM/Contribute/BAO/Contribution.php index 2abaeb5b86..38b1ce7bb5 100644 --- a/CRM/Contribute/BAO/Contribution.php +++ b/CRM/Contribute/BAO/Contribution.php @@ -2129,11 +2129,7 @@ LEFT JOIN civicrm_contribution contribution ON ( componentPayment.contribution_ return $updateResult; } - //now we are ready w/ required ids, start processing. - - $baseIPN = new CRM_Core_Payment_BaseIPN(); - - $input = $ids = $objects = []; + $input = $ids = []; $input['component'] = $componentDetails['component'] ?? NULL; $ids['contribution'] = $contributionId; @@ -2145,14 +2141,16 @@ LEFT JOIN civicrm_contribution contribution ON ( componentPayment.contribution_ $ids['contributionRecur'] = NULL; $ids['contributionPage'] = NULL; - if (!$baseIPN->validateData($input, $ids, $objects, FALSE)) { - throw new CRM_Core_Exception('Unable to validate supplied data'); - } + $contribution = new CRM_Contribute_BAO_Contribution(); + $contribution->id = $ids['contribution']; + $contribution->find(); + + $contribution->loadRelatedObjects($input, $ids); + + $memberships = $contribution->_relatedObjects['membership'] ?? []; + $participant = $contribution->_relatedObjects['participant'] ?? []; + $pledgePayment = $contribution->_relatedObjects['pledge_payment'] ?? []; - $memberships = &$objects['membership']; - $participant = &$objects['participant']; - $pledgePayment = &$objects['pledge_payment']; - $contribution = &$objects['contribution']; $pledgeID = $oldStatus = NULL; $pledgePaymentIDs = []; if ($pledgePayment) { -- 2.25.1