From 570544d5739afbeedda312c1618e97d8afe28c53 Mon Sep 17 00:00:00 2001 From: Bradley Taylor Date: Sat, 26 Feb 2022 17:04:29 +0000 Subject: [PATCH] Remove reference to undefined variable --- CRM/Price/BAO/PriceFieldValue.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CRM/Price/BAO/PriceFieldValue.php b/CRM/Price/BAO/PriceFieldValue.php index 53422f26c4..ae00626f9f 100644 --- a/CRM/Price/BAO/PriceFieldValue.php +++ b/CRM/Price/BAO/PriceFieldValue.php @@ -29,15 +29,15 @@ 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'; - $p = [1 => [$priceFieldID, 'Integer']]; + $query = 'UPDATE civicrm_price_field_value SET is_default = 0 WHERE price_field_id = %1 and id != %2'; + $p = [1 => [$priceFieldID, 'Integer'], 2 => [$fieldValueBAO->id, 'Integer']]; 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; -- 2.25.1