From 01a5d8d498a250e73c11089c392c6587a8907706 Mon Sep 17 00:00:00 2001 From: eileen Date: Mon, 7 Sep 2020 11:00:15 +1200 Subject: [PATCH] Simplify parameters passed to completeOrder Now that completeOrder has had most interaction with objects var cleaned up we know only 2 objects are actually used - contribution - which we can fetch in-function - paymentProcessor - which we were actually only guessing This alters it to only load & pass contribution. The value of passing in processor seems lost in time. This code can only be reached for pay_later contributions - see CRM_Contribute_BAO_Contribution::checkOnlinePendingContribution and specifically https://github.com/civicrm/civicrm-core/blob/318c63045e82d30ed7fe8cdacb91a6d31fc5331b/CRM/Contribute/BAO/Contribution.php#L2033 and only when submitted via an online event (same function) so by definition there IS NO PAYMENT PROCESSOR that applies. Given that we can just do the minimum to load the contribution and pass that in. --- CRM/Event/Form/Task/Batch.php | 42 ++++++----------------------------- 1 file changed, 7 insertions(+), 35 deletions(-) diff --git a/CRM/Event/Form/Task/Batch.php b/CRM/Event/Form/Task/Batch.php index 11341b917d..395feda865 100644 --- a/CRM/Event/Form/Task/Batch.php +++ b/CRM/Event/Form/Task/Batch.php @@ -312,43 +312,15 @@ class CRM_Event_Form_Task_Batch extends CRM_Event_Form_Task { * */ public static function updateContributionStatus($params) { - // get minimum required values. - $componentId = $params['component_id'] ?? NULL; - $contributionId = $params['contribution_id'] ?? NULL; - - $input = $ids = $objects = []; - - //get the required ids. - $ids['contribution'] = $contributionId; - $ids['participant'] = $params['component_id']; - - if (!$ids['contact'] = CRM_Utils_Array::value('contact_id', $params)) { - $ids['contact'] = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_Contribution', - $contributionId, - 'contact_id' - ); - } - - if (!$ids['event'] = CRM_Utils_Array::value('event_id', $params)) { - $ids['event'] = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Participant', - $componentId, - 'event_id' - ); - } - - $input['component'] = 'event'; - - $baseIPN = new CRM_Core_Payment_BaseIPN(); + $input = ['component' => 'event']; // reset template values. $template = CRM_Core_Smarty::singleton(); $template->clearTemplateVars(); - if (!$baseIPN->validateData($input, $ids, $objects, FALSE)) { - throw new CRM_Core_Exception('validation error'); - } - - $contribution = &$objects['contribution']; + $contribution = new CRM_Contribute_BAO_Contribution(); + $contribution->id = $params['contribution_id']; + $contribution->fetch(); $contributionStatuses = CRM_Core_PseudoConstant::get('CRM_Contribute_DAO_Contribution', 'contribution_status_id', [ 'labelColumn' => 'name', @@ -387,10 +359,10 @@ class CRM_Event_Form_Task_Batch extends CRM_Event_Form_Task { // @todo use the api - ie civicrm_api3('Contribution', 'completetransaction', $input); // as this method is not preferred / supported. CRM_Contribute_BAO_Contribution::completeOrder($input, [ - 'related_contact' => $ids['related_contact'] ?? NULL, - 'participant' => !empty($objects['participant']) ? $objects['participant']->id : NULL, + 'related_contact' => NULL, + 'participant' => $params['component_id'], 'contributionRecur' => NULL, - ], $objects); + ], ['contribution' => $contribution]); // reset template values before processing next transactions $template->clearTemplateVars(); -- 2.25.1