add extra validation on config object to prevent save of defective data

This commit is contained in:
Ad Schellevis 2015-03-29 20:17:22 +02:00
parent 49c891985f
commit e07045d9d1

View File

@ -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();
}
}
/**