From cfe3698bb43213a8902c7027dc5b621896e727ad Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Wed, 20 Dec 2023 13:34:47 +1300 Subject: [PATCH] Remove support for pre-2019 usage of core function --- CRM/Contribute/BAO/ContributionRecur.php | 16 +++++++--------- api/v3/ContributionRecur.php | 5 +++-- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/CRM/Contribute/BAO/ContributionRecur.php b/CRM/Contribute/BAO/ContributionRecur.php index 7e7644c151..e6beb6ca2e 100644 --- a/CRM/Contribute/BAO/ContributionRecur.php +++ b/CRM/Contribute/BAO/ContributionRecur.php @@ -275,14 +275,12 @@ class CRM_Contribute_BAO_ContributionRecur extends CRM_Contribute_DAO_Contributi * Recur contribution params * * @return bool + * @throws \CRM_Core_Exception + * @internal + * */ - public static function cancelRecurContribution($params) { - if (is_numeric($params)) { - CRM_Core_Error::deprecatedFunctionWarning('You are using a BAO function whose signature has changed. Please use the ContributionRecur.cancel api'); - $params = ['id' => $params]; - } - $recurId = $params['id']; - if (!$recurId) { + public static function cancelRecurContribution(array $params): bool { + if (!$params['id']) { return FALSE; } $activityParams = [ @@ -292,7 +290,7 @@ class CRM_Contribute_BAO_ContributionRecur extends CRM_Contribute_DAO_Contributi $cancelledId = CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_ContributionRecur', 'contribution_status_id', 'Cancelled'); $recur = new CRM_Contribute_DAO_ContributionRecur(); - $recur->id = $recurId; + $recur->id = $params['id']; $recur->whereAdd("contribution_status_id != $cancelledId"); if ($recur->find(TRUE)) { @@ -303,7 +301,7 @@ class CRM_Contribute_BAO_ContributionRecur extends CRM_Contribute_DAO_Contributi $recur->save(); // @fixme https://lab.civicrm.org/dev/core/issues/927 Cancelling membership etc is not desirable for all use-cases and we should be able to disable it - $dao = CRM_Contribute_BAO_ContributionRecur::getSubscriptionDetails($recurId); + $dao = CRM_Contribute_BAO_ContributionRecur::getSubscriptionDetails($params['id']); if ($dao && $dao->recur_id) { $details = $activityParams['details'] ?? NULL; if ($dao->auto_renew && $dao->membership_id) { diff --git a/api/v3/ContributionRecur.php b/api/v3/ContributionRecur.php index 0294581b2b..9121740712 100644 --- a/api/v3/ContributionRecur.php +++ b/api/v3/ContributionRecur.php @@ -64,10 +64,11 @@ function civicrm_api3_contribution_recur_get($params) { * @param array $params * Array containing id of the recurring contribution. * - * @return bool + * @return array * returns true is successfully cancelled + * @throws \CRM_Core_Exception */ -function civicrm_api3_contribution_recur_cancel($params) { +function civicrm_api3_contribution_recur_cancel(array $params): array { return CRM_Contribute_BAO_ContributionRecur::cancelRecurContribution($params) ? civicrm_api3_create_success() : civicrm_api3_create_error(ts('Error while cancelling recurring contribution')); } -- 2.25.1