From de668aa8a10210d020754191d6fce993c1194e9b Mon Sep 17 00:00:00 2001 From: eileen Date: Mon, 18 Jan 2021 09:56:47 +1300 Subject: [PATCH] [REF] Fix Order class to not reload if already loaded --- CRM/Financial/BAO/Order.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/CRM/Financial/BAO/Order.php b/CRM/Financial/BAO/Order.php index ffe8af8ff9..2779f003a2 100644 --- a/CRM/Financial/BAO/Order.php +++ b/CRM/Financial/BAO/Order.php @@ -176,13 +176,21 @@ class CRM_Financial_BAO_Order { * @param int $id * * @return array - * @throws \CiviCRM_API3_Exception */ public function getPriceFieldSpec(int $id) :array { - if (!isset($this->priceFieldMetadata[$id])) { + return $this->getPriceFieldsMetadata()[$id]; + } + + /** + * Get the metadata for the fields in the price set. + * + * @return array + */ + public function getPriceFieldsMetadata(): array { + if (empty($this->priceFieldMetadata)) { $this->priceFieldMetadata = CRM_Price_BAO_PriceSet::getCachedPriceSetDetail($this->getPriceSetID())['fields']; } - return $this->priceFieldMetadata[$id]; + return $this->priceFieldMetadata; } /** @@ -193,7 +201,7 @@ class CRM_Financial_BAO_Order { * * @param array $input */ - public function setPriceSelectionFromUnfilteredInput(array $input) { + public function setPriceSelectionFromUnfilteredInput(array $input): void { foreach ($input as $fieldName => $value) { if (strpos($fieldName, 'price_') === 0) { $fieldID = substr($fieldName, 6); -- 2.25.1