Skip to content

Commit

Permalink
MVC, treat an empty ArrayField as non existent, closes #3123
Browse files Browse the repository at this point in the history
  • Loading branch information
AdSchellevis committed Jan 17, 2019
1 parent 6d11ffc commit a111b34
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/opnsense/mvc/app/models/OPNsense/Base/BaseModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ private function getNewField($classname)
* @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)
{
Expand Down Expand Up @@ -223,7 +224,7 @@ private function parseXml(&$xml, &$config_data, &$internal_data)

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)) {
Expand Down Expand Up @@ -263,6 +264,7 @@ private function parseXml(&$xml, &$config_data, &$internal_data)
/**
* 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()
{
Expand Down Expand Up @@ -360,6 +362,7 @@ public function getNodes()
* structured setter for model
* @param array|$data named array
* @return array
* @throws \Exception
*/
public function setNodes($data)
{
Expand Down Expand Up @@ -588,6 +591,7 @@ public function setNodeByReference($reference, $value)
* 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()
{
Expand Down

0 comments on commit a111b34

Please sign in to comment.