diff --git a/CRM/Contribute/BAO/Contribution.php b/CRM/Contribute/BAO/Contribution.php index f4f5f4fbea75..bb3dfe486a67 100644 --- a/CRM/Contribute/BAO/Contribution.php +++ b/CRM/Contribute/BAO/Contribution.php @@ -2079,26 +2079,22 @@ public static function checkOnlinePendingContribution($componentId, $componentNa * */ public static function transitionComponents($params) { + $contributionStatus = CRM_Core_PseudoConstant::getName('CRM_Contribute_BAO_Contribution', 'contribution_status_id', $params['contribution_status_id']); + $previousStatus = CRM_Core_PseudoConstant::getName('CRM_Contribute_BAO_Contribution', 'contribution_status_id', $params['previous_contribution_status_id']); // @todo fix the one place that calls this function to use Payment.create // remove this. // get minimum required values. - $contactId = $params['contact_id'] ?? NULL; - $componentId = $params['component_id'] ?? NULL; - $componentName = $params['componentName'] ?? NULL; - $contributionId = $params['contribution_id'] ?? NULL; - $contributionStatusId = $params['contribution_status_id'] ?? NULL; + $contactId = NULL; + $componentId = NULL; + $componentName = NULL; + $contributionId = $params['contribution_id']; + $contributionStatusId = $params['contribution_status_id']; // if we already processed contribution object pass previous status id. - $previousContriStatusId = $params['previous_contribution_status_id'] ?? NULL; - - $contributionStatuses = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name'); + $previousContriStatusId = $params['previous_contribution_status_id']; // we process only ( Completed, Cancelled, or Failed ) contributions. - if (!$contributionId || - !in_array($contributionStatusId, [ - array_search('Completed', $contributionStatuses), - ]) - ) { + if (!$contributionId || $contributionStatus !== 'Completed') { return; } @@ -2170,11 +2166,11 @@ public static function transitionComponents($params) { 'status_id' ); } - if ($contributionStatusId == array_search('Completed', $contributionStatuses)) { + if ($contributionStatus === 'Completed') { // only pending contribution related object processed. if ($previousContriStatusId && - !in_array($contributionStatuses[$previousContriStatusId], [ + !in_array($previousStatus, [ 'Pending', 'Partially paid', ]) @@ -2183,7 +2179,7 @@ public static function transitionComponents($params) { return; } elseif (!$previousContriStatusId && - !in_array($contributionStatuses[$contribution->contribution_status_id], [ + !in_array($contributionStatus, [ 'Pending', 'Partially paid', ])