diff --git a/src/opnsense/mvc/app/library/OPNsense/Core/Config.php b/src/opnsense/mvc/app/library/OPNsense/Core/Config.php index c8f10a1a2..23c0ded02 100644 --- a/src/opnsense/mvc/app/library/OPNsense/Core/Config.php +++ b/src/opnsense/mvc/app/library/OPNsense/Core/Config.php @@ -140,6 +140,12 @@ class Config extends Singleton if ($node == null) { $this->simplexml = simplexml_load_string('<'.$this->simplexml[0]->getName().'/>'); $node = $this->simplexml ; + // invalidate object on warnings/errors (prevent save from happening) + set_error_handler( + function() { + $this->statusIsValid = false; + } + ); } foreach ($source as $itemKey => $itemValue) { @@ -166,6 +172,11 @@ class Config extends Singleton $childNode[0] = $itemValue; } } + + // restore error handling on initial call + if ($node == $this->simplexml) { + restore_error_handler(); + } } /**