From a111b345ffe29410844aeb95f2979237bb3094f0 Mon Sep 17 00:00:00 2001 From: Ad Schellevis Date: Thu, 17 Jan 2019 17:10:24 +0100 Subject: [PATCH] MVC, treat an empty ArrayField as non existent, closes https://github.com/opnsense/core/issues/3123 --- src/opnsense/mvc/app/models/OPNsense/Base/BaseModel.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/opnsense/mvc/app/models/OPNsense/Base/BaseModel.php b/src/opnsense/mvc/app/models/OPNsense/Base/BaseModel.php index db62db3de..3dc3ae311 100644 --- a/src/opnsense/mvc/app/models/OPNsense/Base/BaseModel.php +++ b/src/opnsense/mvc/app/models/OPNsense/Base/BaseModel.php @@ -149,6 +149,7 @@ abstract class BaseModel * @param SimpleXMLElement $config_data (current) config data * @param BaseField $internal_data output structure using FieldTypes,rootnode is internalData * @throws ModelException parse error + * @throws \ReflectionException */ private function parseXml(&$xml, &$config_data, &$internal_data) { @@ -223,7 +224,7 @@ abstract class BaseModel if ($fieldObject instanceof ArrayField) { // handle Array types, recurring items - if ($config_section_data != null) { + if ($config_section_data != null && !empty((string)$config_section_data)) { foreach ($config_section_data as $conf_section) { // Array items are identified by a UUID, read from attribute or create a new one if (isset($conf_section->attributes()->uuid)) { @@ -263,6 +264,7 @@ abstract class BaseModel /** * Construct new model type, using it's own xml template * @throws ModelException if the model xml is not found or invalid + * @throws \ReflectionException */ public function __construct() { @@ -360,6 +362,7 @@ abstract class BaseModel * structured setter for model * @param array|$data named array * @return array + * @throws \Exception */ public function setNodes($data) { @@ -588,6 +591,7 @@ abstract class BaseModel * prefixed with an M and . replaced by _ for example : M1_0_1 equals version 1.0.1 * * @return bool status (true-->success, false-->failed) + * @throws \ReflectionException */ public function runMigrations() {