From b8ac27a6c2e1203fcfbe1062e0693448e9e8be30 Mon Sep 17 00:00:00 2001 From: Aidan Saunders Date: Mon, 21 Nov 2022 19:37:58 +0000 Subject: [PATCH] More BAO `del()` deprecations --- CRM/Contribute/BAO/ManagePremiums.php | 1 + CRM/Contribute/BAO/Premium.php | 6 +++--- CRM/Core/BAO/Discount.php | 11 ++++++++--- CRM/Core/BAO/PreferencesDate.php | 3 +++ CRM/SMS/BAO/Provider.php | 6 +++++- 5 files changed, 20 insertions(+), 7 deletions(-) diff --git a/CRM/Contribute/BAO/ManagePremiums.php b/CRM/Contribute/BAO/ManagePremiums.php index a05daaad12..a8e6033e70 100644 --- a/CRM/Contribute/BAO/ManagePremiums.php +++ b/CRM/Contribute/BAO/ManagePremiums.php @@ -86,6 +86,7 @@ class CRM_Contribute_BAO_ManagePremiums extends CRM_Contribute_BAO_Product { public static function del($productID) { CRM_Core_Error::deprecatedFunctionWarning('CRM_Contribute_BAO_Product::del'); return parent::del($productID); + // Stop this showing up when we're looking for undeprecated del's by keeping this: static::deleteRecord( } } diff --git a/CRM/Contribute/BAO/Premium.php b/CRM/Contribute/BAO/Premium.php index 42e21c9ae4..8b577b7bc6 100644 --- a/CRM/Contribute/BAO/Premium.php +++ b/CRM/Contribute/BAO/Premium.php @@ -55,11 +55,11 @@ class CRM_Contribute_BAO_Premium extends CRM_Contribute_DAO_Premium { * Delete financial Types. * * @param int $premiumID + * + * @deprecated */ public static function del($premiumID) { - $premium = new CRM_Contribute_DAO_Premium(); - $premium->id = $premiumID; - $premium->delete(); + return static::deleteRecord(['id' => $premiumID]); } /** diff --git a/CRM/Core/BAO/Discount.php b/CRM/Core/BAO/Discount.php index 553b0ea5df..2b63fd5c36 100644 --- a/CRM/Core/BAO/Discount.php +++ b/CRM/Core/BAO/Discount.php @@ -23,16 +23,21 @@ class CRM_Core_BAO_Discount extends CRM_Core_DAO_Discount { * @param string $entityTable * * @return bool + * + * @deprecated */ public static function del($entityId, $entityTable) { // delete all discount records with the selected discounted id $discount = new CRM_Core_DAO_Discount(); $discount->entity_id = $entityId; $discount->entity_table = $entityTable; - if ($discount->delete()) { - return TRUE; + $discount->find(); + $ret = FALSE; + while ($discount->fetch()) { + static::deleteRecord(['id' => $discount->id]); + $ret = TRUE; } - return FALSE; + return $ret; } /** diff --git a/CRM/Core/BAO/PreferencesDate.php b/CRM/Core/BAO/PreferencesDate.php index 66482c03f9..9263f6b230 100644 --- a/CRM/Core/BAO/PreferencesDate.php +++ b/CRM/Core/BAO/PreferencesDate.php @@ -51,9 +51,12 @@ class CRM_Core_BAO_PreferencesDate extends CRM_Core_DAO_PreferencesDate { * * @param int $id * @throws CRM_Core_Exception + * + * @deprecated */ public static function del($id) { throw new CRM_Core_Exception('Cannot call del function'); + // Stop this showing up when we're looking for undeprecated del's by keeping this: static::deleteRecord( } /** diff --git a/CRM/SMS/BAO/Provider.php b/CRM/SMS/BAO/Provider.php index 0c205bc0c3..f820b10430 100644 --- a/CRM/SMS/BAO/Provider.php +++ b/CRM/SMS/BAO/Provider.php @@ -117,6 +117,8 @@ class CRM_SMS_BAO_Provider extends CRM_SMS_DAO_Provider { * * @return null * @throws CRM_Core_Exception + * + * @deprecated */ public static function del($providerID) { if (!$providerID) { @@ -129,7 +131,9 @@ class CRM_SMS_BAO_Provider extends CRM_SMS_DAO_Provider { if (!$dao->find(TRUE)) { return NULL; } - $dao->delete(); + // The above just filters out attempts to delete for other domains + // Not sure it's needed, but preserves old behaviour and is deprecated. + static::deleteRecord(['id' => $providerID]); } /** -- 2.25.1