Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Ref] Clarify what parameters are passed in #21063

Merged
merged 1 commit into from
Aug 9, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 12 additions & 16 deletions CRM/Contribute/BAO/Contribution.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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',
])
Expand All @@ -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',
])
Expand Down