From 7fb27138be1db7a9715d00b42993ad912a811d81 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Wed, 20 May 2020 09:04:32 -0400 Subject: [PATCH] Fix notice and redundant code in PriceFieldValue BAO --- CRM/Price/BAO/PriceFieldValue.php | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/CRM/Price/BAO/PriceFieldValue.php b/CRM/Price/BAO/PriceFieldValue.php index 7806a6c4dc..7ad8514b75 100644 --- a/CRM/Price/BAO/PriceFieldValue.php +++ b/CRM/Price/BAO/PriceFieldValue.php @@ -61,7 +61,7 @@ class CRM_Price_BAO_PriceFieldValue extends CRM_Price_DAO_PriceFieldValue { return NULL; } if (!$id && empty($params['name'])) { - $params['name'] = strtolower(CRM_Utils_String::munge($params['label'], '_', 242)); + $params['name'] = strtolower(CRM_Utils_String::munge(($params['label'] ?? '_'), '_', 242)); } if ($id && !empty($params['weight'])) { @@ -76,13 +76,8 @@ class CRM_Price_BAO_PriceFieldValue extends CRM_Price_DAO_PriceFieldValue { $fieldValues = ['price_field_id' => CRM_Utils_Array::value('price_field_id', $params, 0)]; $params['weight'] = CRM_Utils_Weight::updateOtherWeights('CRM_Price_DAO_PriceFieldValue', $oldWeight, $params['weight'], $fieldValues); } - else { - if (!$id) { - CRM_Core_DAO::setCreateDefaults($params, self::getDefaults()); - if (empty($params['name'])) { - $params['name'] = CRM_Utils_String::munge(CRM_Utils_Array::value('label', $params), '_', 64); - } - } + elseif (!$id) { + CRM_Core_DAO::setCreateDefaults($params, self::getDefaults()); } $financialType = $params['financial_type_id'] ?? NULL; -- 2.25.1