From 776d6522f797ac3114378141179d8594427a1c58 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Wed, 1 Mar 2023 08:30:02 +1300 Subject: [PATCH] Php8.2 stop accessing undefined form Property isQuickConfig in PriceField:addQuickFormElement --- CRM/Price/BAO/PriceField.php | 11 ++++++----- CRM/Price/BAO/PriceSet.php | 17 +++++++++++++++-- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/CRM/Price/BAO/PriceField.php b/CRM/Price/BAO/PriceField.php index 163f553eab..b76d95c321 100644 --- a/CRM/Price/BAO/PriceField.php +++ b/CRM/Price/BAO/PriceField.php @@ -268,6 +268,7 @@ class CRM_Price_BAO_PriceField extends CRM_Price_DAO_PriceField { } $is_pay_later = 0; + $isQuickConfig = CRM_Price_BAO_PriceSet::isQuickConfig($field->price_set_id); if (isset($qf->_mode) && empty($qf->_mode)) { $is_pay_later = 1; } @@ -324,13 +325,13 @@ class CRM_Price_BAO_PriceField extends CRM_Price_DAO_PriceField { ]); $extra = []; - if (!empty($qf->_membershipBlock) && !empty($qf->_quickConfig) && $field->name == 'other_amount' && empty($qf->_contributionAmount)) { + if (!empty($qf->_membershipBlock) && $isQuickConfig && $field->name == 'other_amount' && empty($qf->_contributionAmount)) { $useRequired = 0; } elseif (!empty($fieldOptions[$optionKey]['label'])) { //check for label. $label = $fieldOptions[$optionKey]['label']; - if (!empty($qf->_quickConfig) && !empty($qf->_contributionAmount) && strtolower($fieldOptions[$optionKey]['name']) == 'other_amount') { + if ($isQuickConfig && !empty($qf->_contributionAmount) && strtolower($fieldOptions[$optionKey]['name']) == 'other_amount') { $label .= ' ' . $currencySymbol; $qf->assign('priceset', $elementName); $extra = [ @@ -361,7 +362,7 @@ class CRM_Price_BAO_PriceField extends CRM_Price_DAO_PriceField { } //CRM-10117 - if (!empty($qf->_quickConfig)) { + if ($isQuickConfig) { $message = ts('Please enter a valid amount.'); $type = 'money'; } @@ -376,7 +377,7 @@ class CRM_Price_BAO_PriceField extends CRM_Price_DAO_PriceField { case 'Radio': $choice = []; - if (!empty($qf->_quickConfig) && !empty($qf->_contributionAmount)) { + if ($isQuickConfig && !empty($qf->_contributionAmount)) { $qf->assign('contriPriceset', $elementName); } @@ -418,7 +419,7 @@ class CRM_Price_BAO_PriceField extends CRM_Price_DAO_PriceField { 'data-price-field-values' => json_encode($customOption), 'visibility' => $visibility_id, ]; - if (!empty($qf->_quickConfig) && $field->name == 'contribution_amount') { + if ($isQuickConfig && $field->name == 'contribution_amount') { $extra += ['onclick' => 'clearAmountOther();']; } if ($field->name == 'membership_amount') { diff --git a/CRM/Price/BAO/PriceSet.php b/CRM/Price/BAO/PriceSet.php index 30de2eaf36..982115ed82 100644 --- a/CRM/Price/BAO/PriceSet.php +++ b/CRM/Price/BAO/PriceSet.php @@ -509,6 +509,20 @@ WHERE id = %1"; return $setTree; } + /** + * Is the price set 'quick config'. + * + * Quick config price sets have a simplified configuration on + * contribution and event pages. + * + * @param int $priceSetID + * + * @return bool + */ + public static function isQuickConfig(int $priceSetID): bool { + return (bool) self::getCachedPriceSetDetail($priceSetID)['is_quick_config']; + } + /** * Get the Price Field ID. * @@ -1320,8 +1334,7 @@ WHERE ps.id = %1 public static function copyPriceSet($baoName, $id, $newId) { $priceSetId = CRM_Price_BAO_PriceSet::getFor($baoName, $id); if ($priceSetId) { - $isQuickConfig = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $priceSetId, 'is_quick_config'); - if ($isQuickConfig) { + if (self::isQuickConfig($priceSetId)) { $copyPriceSet = CRM_Price_BAO_PriceSet::copy($priceSetId); CRM_Price_BAO_PriceSet::addTo($baoName, $newId, $copyPriceSet->id); } -- 2.25.1