From b0f3e131f5b08397f6ebf7149778541b99d9bb45 Mon Sep 17 00:00:00 2001 From: Ad Schellevis Date: Mon, 23 Oct 2023 16:59:13 +0200 Subject: [PATCH] mvc/OptionField type - fix regression in https://github.com/opnsense/core/commit/bc195308be01698a3cff3e8c375d2646b8576b37 , can't make choices static, unless we would serialize $data's payload first. to avoid further issues, just go back to always setting the values. --- .../OPNsense/Base/FieldTypes/OptionField.php | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/OptionField.php b/src/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/OptionField.php index 8e1fbaf8d..488e1cb16 100644 --- a/src/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/OptionField.php +++ b/src/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/OptionField.php @@ -34,26 +34,21 @@ namespace OPNsense\Base\FieldTypes; */ class OptionField extends BaseListField { - /** - * @var string static option list, no need to parse the same structure multiple times - */ - private static $internalCacheOptionList = []; - /** * setter for option values * @param $data */ public function setOptionValues($data) { - if (is_array($data) && empty(self::$internalCacheOptionList)) { - self::$internalCacheOptionList = []; + if (is_array($data)) { + $this->internalOptionList = []; // copy options to internal structure, make sure we don't copy in array structures foreach ($data as $key => $value) { if (!is_array($value)) { - self::$internalCacheOptionList[$key] = gettext($value); + $this->internalOptionList[$key] = gettext($value); } else { foreach ($value as $subkey => $subval) { - self::$internalCacheOptionList[$subkey] = [ + $this->internalOptionList[$subkey] = [ 'value' => $subval, 'optgroup' => $key ]; @@ -61,6 +56,5 @@ class OptionField extends BaseListField } } } - $this->internalOptionList = self::$internalCacheOptionList; } }