Skip to content

Commit

Permalink
Merge pull request #22839 from braders/pricefieldvalue-undefined-var
Browse files Browse the repository at this point in the history
Remove reference to undefined variable
  • Loading branch information
demeritcowboy authored Feb 26, 2022
2 parents 1f3e4c2 + 570544d commit e4339d1
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions CRM/Price/BAO/PriceFieldValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit e4339d1

Please sign in to comment.