More BAO `del()` deprecations
authorAidan Saunders <aidan.saunders@squiffle.uk>
Mon, 21 Nov 2022 19:37:58 +0000 (19:37 +0000)
committerAidan Saunders <aidan.saunders@squiffle.uk>
Mon, 21 Nov 2022 19:37:58 +0000 (19:37 +0000)
CRM/Contribute/BAO/ManagePremiums.php
CRM/Contribute/BAO/Premium.php
CRM/Core/BAO/Discount.php
CRM/Core/BAO/PreferencesDate.php
CRM/SMS/BAO/Provider.php

index a05daaad12d2f3dc6823369744d983bf8f684853..a8e6033e70ab84e68314085657ff0da50649c968 100644 (file)
@@ -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(
   }
 
 }
index 42e21c9ae4496a465c546f88a222bf7318e590f6..8b577b7bc6aeea0c88f30949d3f6dc66eda0b56d 100644 (file)
@@ -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]);
   }
 
   /**
index 553b0ea5dfd6c9faf4c41d948d2058e8e3cd5c8e..2b63fd5c363519dd86d60f8cc561622fce525e9f 100644 (file)
@@ -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;
   }
 
   /**
index 66482c03f94ccd572406023db269fb7180ede296..9263f6b230e0c52dd00dbb4d00e8bcd9895164bb 100644 (file)
@@ -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(
   }
 
   /**
index 0c205bc0c30b74b7435ebfde2c856da57761dfb1..f820b10430d62f52afc58118be5385dba59772b8 100644 (file)
@@ -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]);
   }
 
   /**