From 4dd166180c4e8184d753ca2f0686ef163716305f Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Sat, 17 Sep 2022 11:37:06 +1200 Subject: [PATCH] Remove call to deprecated function CRM_Contribute_PseudoConstant::contributionStatus --- CRM/Contribute/BAO/Contribution.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/CRM/Contribute/BAO/Contribution.php b/CRM/Contribute/BAO/Contribution.php index d3f3cb5d32ea..714c8811ad72 100644 --- a/CRM/Contribute/BAO/Contribution.php +++ b/CRM/Contribute/BAO/Contribution.php @@ -3049,10 +3049,9 @@ public static function recordFinancialAccounts(&$params, CRM_Contribute_DAO_Cont $isUpdate = !empty($params['prevContribution']); $additionalParticipantId = []; - $contributionStatuses = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name'); - $contributionStatus = empty($params['contribution_status_id']) ? NULL : $contributionStatuses[$params['contribution_status_id']]; + $contributionStatus = CRM_Core_PseudoConstant::getName('CRM_Contribute_BAO_Contribution', 'contribution_status_id', $params['contribution_status_id'] ?? NULL); - if (CRM_Utils_Array::value('contribution_mode', $params) == 'participant') { + if (CRM_Utils_Array::value('contribution_mode', $params) === 'participant') { $entityId = $params['participant_id']; $entityTable = 'civicrm_participant'; $additionalParticipantId = CRM_Event_BAO_Participant::getAdditionalParticipantIds($entityId); @@ -3083,8 +3082,8 @@ public static function recordFinancialAccounts(&$params, CRM_Contribute_DAO_Cont $statusId = $params['contribution']->contribution_status_id; - if ($contributionStatus != 'Failed' && - !($contributionStatus == 'Pending' && !$params['contribution']->is_pay_later) + if ($contributionStatus !== 'Failed' && + !($contributionStatus === 'Pending' && !$params['contribution']->is_pay_later) ) { $skipRecords = TRUE; $pendingStatus = [ @@ -3148,7 +3147,7 @@ public static function recordFinancialAccounts(&$params, CRM_Contribute_DAO_Cont 'pan_truncation' => $params['pan_truncation'] ?? NULL, 'card_type_id' => $params['card_type_id'] ?? NULL, ]; - if ($contributionStatus == 'Refunded' || $contributionStatus == 'Chargeback' || $contributionStatus == 'Cancelled') { + if ($contributionStatus === 'Refunded' || $contributionStatus === 'Chargeback' || $contributionStatus === 'Cancelled') { $trxnParams['trxn_date'] = !empty($params['contribution']->cancel_date) ? $params['contribution']->cancel_date : date('YmdHis'); if (isset($params['refund_trxn_id'])) { // CRM-17751 allow a separate trxn_id for the refund to be passed in via api & form. @@ -3340,7 +3339,7 @@ public static function recordFinancialAccounts(&$params, CRM_Contribute_DAO_Cont CRM_Core_BAO_FinancialTrxn::recordFees($params); } - if (!empty($params['prevContribution']) && $entityTable == 'civicrm_participant' + if (!empty($params['prevContribution']) && $entityTable === 'civicrm_participant' && $params['prevContribution']->contribution_status_id != $params['contribution']->contribution_status_id ) { $eventID = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Participant', $entityId, 'event_id');