Merge pull request #22333 from mlutfy/fixTsRecaptcha
[civicrm-core.git] / CRM / Price / BAO / PriceFieldValue.php
index 7ad8514b754ee96b6276545d4853dc7ba137a023..5df67efec829ad5482625d3daac366f7b63afa8a 100644 (file)
@@ -29,8 +29,6 @@ class CRM_Price_BAO_PriceFieldValue extends CRM_Price_DAO_PriceFieldValue {
    * @return CRM_Price_DAO_PriceFieldValue
    */
   public static function add($params) {
-    $fieldValueBAO = self::writeRecord($params);
-
     if (!empty($params['is_default'])) {
       $priceFieldID = $params['price_field_id'] ?? CRM_Core_DAO::getFieldValue('CRM_Price_BAO_PriceFieldValue', $fieldValueBAO->id, 'price_field_id');
       $query = 'UPDATE civicrm_price_field_value SET is_default = 0 WHERE  price_field_id = %1';
@@ -38,6 +36,8 @@ class CRM_Price_BAO_PriceFieldValue extends CRM_Price_DAO_PriceFieldValue {
       CRM_Core_DAO::executeQuery($query, $p);
     }
 
+    $fieldValueBAO = self::writeRecord($params);
+
     // Reset the cached values in this function.
     CRM_Price_BAO_PriceField::getOptions(CRM_Utils_Array::value('price_field_id', $params), FALSE, TRUE);
     return $fieldValueBAO;
@@ -217,19 +217,12 @@ class CRM_Price_BAO_PriceFieldValue extends CRM_Price_DAO_PriceFieldValue {
    * Delete the value.
    *
    * @param int $id
-   *   Id.
    *
+   * @deprecated
    * @return bool
-   *
    */
   public static function del($id) {
-    if (!$id) {
-      return FALSE;
-    }
-
-    $fieldValueDAO = new CRM_Price_DAO_PriceFieldValue();
-    $fieldValueDAO->id = $id;
-    return $fieldValueDAO->delete();
+    return (bool) self::deleteRecord(['id' => $id]);
   }
 
   /**