Reflect format errors in is_valid() method to avoid invalid data being loadd and written to cache (#2360)
This commit is contained in:
parent
fbf3207dfb
commit
29ab9b594e
8 changed files with 15 additions and 8 deletions
|
@ -40,6 +40,7 @@ abstract class kolab_format
|
|||
protected $data;
|
||||
protected $xmldata;
|
||||
protected $xmlobject;
|
||||
protected $formaterror;
|
||||
protected $loaded = false;
|
||||
protected $version = '3.0';
|
||||
|
||||
|
@ -248,7 +249,7 @@ abstract class kolab_format
|
|||
$log = "Error";
|
||||
}
|
||||
|
||||
if ($log) {
|
||||
if ($log && !isset($this->formaterror)) {
|
||||
rcube::raise_error(array(
|
||||
'code' => 660,
|
||||
'type' => 'php',
|
||||
|
@ -256,6 +257,8 @@ abstract class kolab_format
|
|||
'line' => __LINE__,
|
||||
'message' => "kolabformat $log: " . kolabformat::errorMessage(),
|
||||
), true);
|
||||
|
||||
$this->formaterror = $ret;
|
||||
}
|
||||
|
||||
return $ret;
|
||||
|
@ -342,6 +345,7 @@ abstract class kolab_format
|
|||
*/
|
||||
public function load($xml)
|
||||
{
|
||||
$this->formaterror = null;
|
||||
$read_func = $this->libfunc($this->read_func);
|
||||
|
||||
if (is_array($read_func))
|
||||
|
@ -365,6 +369,8 @@ abstract class kolab_format
|
|||
*/
|
||||
public function write($version = null)
|
||||
{
|
||||
$this->formaterror = null;
|
||||
|
||||
$this->init();
|
||||
$write_func = $this->libfunc($this->write_func);
|
||||
if (is_array($write_func))
|
||||
|
|
|
@ -268,7 +268,7 @@ class kolab_format_contact extends kolab_format
|
|||
*/
|
||||
public function is_valid()
|
||||
{
|
||||
return $this->data || (is_object($this->obj) && $this->obj->uid() /*$this->obj->isValid()*/);
|
||||
return !$this->formaterror && ($this->data || (is_object($this->obj) && $this->obj->uid() /*$this->obj->isValid()*/));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -69,7 +69,7 @@ class kolab_format_distributionlist extends kolab_format
|
|||
|
||||
public function is_valid()
|
||||
{
|
||||
return $this->data || (is_object($this->obj) && $this->obj->isValid());
|
||||
return !$this->formaterror && ($this->data || (is_object($this->obj) && $this->obj->isValid()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -111,7 +111,8 @@ class kolab_format_event extends kolab_format_xcal
|
|||
*/
|
||||
public function is_valid()
|
||||
{
|
||||
return $this->data || (is_object($this->obj) && $this->obj->isValid() && $this->obj->uid());
|
||||
return !$this->formaterror && (($this->data && !empty($this->data['start']) && !empty($this->data['end'])) ||
|
||||
(is_object($this->obj) && $this->obj->isValid() && $this->obj->uid()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -95,7 +95,7 @@ class kolab_format_file extends kolab_format
|
|||
*/
|
||||
public function is_valid()
|
||||
{
|
||||
return $this->data || (is_object($this->obj) && $this->obj->isValid());
|
||||
return !$this->formaterror && ($this->data || (is_object($this->obj) && $this->obj->isValid()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -54,7 +54,7 @@ class kolab_format_journal extends kolab_format
|
|||
*/
|
||||
public function is_valid()
|
||||
{
|
||||
return $this->data || (is_object($this->obj) && $this->obj->isValid());
|
||||
return !$this->formaterror && ($this->data || (is_object($this->obj) && $this->obj->isValid()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -54,7 +54,7 @@ class kolab_format_note extends kolab_format
|
|||
*/
|
||||
public function is_valid()
|
||||
{
|
||||
return $this->data || (is_object($this->obj) && $this->obj->isValid());
|
||||
return !$this->formaterror && ($this->data || (is_object($this->obj) && $this->obj->isValid()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -63,7 +63,7 @@ class kolab_format_task extends kolab_format_xcal
|
|||
*/
|
||||
public function is_valid()
|
||||
{
|
||||
return $this->data || (is_object($this->obj) && $this->obj->isValid());
|
||||
return !$this->formaterror && ($this->data || (is_object($this->obj) && $this->obj->isValid()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Reference in a new issue