From: eileen Date: Sun, 17 Jan 2021 20:56:47 +0000 (+1300) Subject: [REF] Fix Order class to not reload if already loaded X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=de668aa8a10210d020754191d6fce993c1194e9b;p=civicrm-core.git [REF] Fix Order class to not reload if already loaded --- 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);