From 65b0b7c2d8bcf27a77113d5ee93692ce9b9d39d7 Mon Sep 17 00:00:00 2001 From: eileen Date: Tue, 1 Sep 2020 15:21:50 +1200 Subject: [PATCH] [REF] Clean up return variables on updateContributionStatus, updatePendingOnlineContribution The return variable from updatePendingOnlineContribution is never used - ergo don't return it. This means the return value from updateContributionStatus is also never used - ergo - you get it. In addition don't call the function with empty variables - I've moved the check as to whether they are empty into the calling function - although likely in a second pass the checks will be removed or change again --- CRM/Event/Form/Task/Batch.php | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/CRM/Event/Form/Task/Batch.php b/CRM/Event/Form/Task/Batch.php index f39d72ac20..16d8752bde 100644 --- a/CRM/Event/Form/Task/Batch.php +++ b/CRM/Event/Form/Task/Batch.php @@ -260,14 +260,10 @@ class CRM_Event_Form_Task_Batch extends CRM_Event_Form_Task { * @param int $participantId * @param int $statusId * - * @return mixed * @throws \CRM_Core_Exception * @throws \CiviCRM_API3_Exception */ public static function updatePendingOnlineContribution($participantId, $statusId) { - if (!$participantId || !$statusId) { - return NULL; - } $contributionId = CRM_Contribute_BAO_Contribution::checkOnlinePendingContribution($participantId, 'Event' @@ -292,7 +288,7 @@ class CRM_Event_Form_Task_Batch extends CRM_Event_Form_Task { $contributionStatusId = array_search('Cancelled', $contributionStatuses); } - if (!$contributionStatusId) { + if (!$contributionStatusId || !$participantId || !$contributionId) { return; } @@ -305,9 +301,7 @@ class CRM_Event_Form_Task_Batch extends CRM_Event_Form_Task { ]; //change related contribution status. - $updatedStatusId = self::updateContributionStatus($params); - - return $updatedStatusId; + self::updateContributionStatus($params); } /** @@ -315,7 +309,6 @@ class CRM_Event_Form_Task_Batch extends CRM_Event_Form_Task { * * @param array $params * - * @return NULL|int * @throws \CRM_Core_Exception * @throws \CiviCRM_API3_Exception * @throws \Exception @@ -332,10 +325,6 @@ class CRM_Event_Form_Task_Batch extends CRM_Event_Form_Task { $componentName = $params['componentName'] ?? NULL; $contributionId = $params['contribution_id'] ?? NULL; - if (!$contributionId || !$componentId || !$componentName || !$statusId) { - return NULL; - } - $input = $ids = $objects = []; //get the required ids. @@ -389,13 +378,13 @@ class CRM_Event_Form_Task_Batch extends CRM_Event_Form_Task { $transaction = new CRM_Core_Transaction(); $baseIPN->cancelled($objects, $transaction, $input); $transaction->commit(); - return $statusId; + return; } - elseif ($statusId == $contributionStatuses['Failed']) { + if ($statusId == $contributionStatuses['Failed']) { $transaction = new CRM_Core_Transaction(); $baseIPN->failed($objects, $transaction, $input); $transaction->commit(); - return $statusId; + return; } // status is not pending @@ -432,8 +421,6 @@ class CRM_Event_Form_Task_Batch extends CRM_Event_Form_Task { // reset template values before processing next transactions $template->clearTemplateVars(); - - return $statusId; } /** @@ -513,7 +500,7 @@ class CRM_Event_Form_Task_Batch extends CRM_Event_Form_Task { if ($statusChange) { CRM_Event_BAO_Participant::transitionParticipants([$key], $value['status_id'], $fromStatusId); } - if ($relatedStatusChange) { + if ($relatedStatusChange && $key && $value['status_id']) { //update related contribution status, CRM-4395 self::updatePendingOnlineContribution($key, $value['status_id']); } -- 2.25.1