summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Bruederli <bruederli@kolabsys.com>2013-10-16 13:30:51 (GMT)
committerThomas Bruederli <bruederli@kolabsys.com>2013-10-16 13:33:52 (GMT)
commit977b9d8ad75844684e8ff8aa210e761add733dd1 (patch)
treea20cff9a06f41f246e3a2011075c198dd2592230
parentc6471146b94e411726b902c3b05bf94255f4e0e6 (diff)
downloadroundcubemail-plugins-kolab-977b9d8ad75844684e8ff8aa210e761add733dd1.tar.gz
Reflect format errors in is_valid() method to avoid invalid data being loadd and written to cache (#2360)
-rw-r--r--plugins/libkolab/lib/kolab_format.php8
-rw-r--r--plugins/libkolab/lib/kolab_format_contact.php2
-rw-r--r--plugins/libkolab/lib/kolab_format_distributionlist.php2
-rw-r--r--plugins/libkolab/lib/kolab_format_event.php3
-rw-r--r--plugins/libkolab/lib/kolab_format_file.php2
-rw-r--r--plugins/libkolab/lib/kolab_format_journal.php2
-rw-r--r--plugins/libkolab/lib/kolab_format_note.php2
-rw-r--r--plugins/libkolab/lib/kolab_format_task.php2
8 files changed, 15 insertions, 8 deletions
diff --git a/plugins/libkolab/lib/kolab_format.php b/plugins/libkolab/lib/kolab_format.php
index dc95c76..d74d697 100644
--- a/plugins/libkolab/lib/kolab_format.php
+++ b/plugins/libkolab/lib/kolab_format.php
@@ -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))
diff --git a/plugins/libkolab/lib/kolab_format_contact.php b/plugins/libkolab/lib/kolab_format_contact.php
index 72867fc..0d0bc75 100644
--- a/plugins/libkolab/lib/kolab_format_contact.php
+++ b/plugins/libkolab/lib/kolab_format_contact.php
@@ -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()*/));
}
/**
diff --git a/plugins/libkolab/lib/kolab_format_distributionlist.php b/plugins/libkolab/lib/kolab_format_distributionlist.php
index 304cdc4..46dda01 100644
--- a/plugins/libkolab/lib/kolab_format_distributionlist.php
+++ b/plugins/libkolab/lib/kolab_format_distributionlist.php
@@ -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()));
}
/**
diff --git a/plugins/libkolab/lib/kolab_format_event.php b/plugins/libkolab/lib/kolab_format_event.php
index e5ea3ef..9be9bdf 100644
--- a/plugins/libkolab/lib/kolab_format_event.php
+++ b/plugins/libkolab/lib/kolab_format_event.php
@@ -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()));
}
/**
diff --git a/plugins/libkolab/lib/kolab_format_file.php b/plugins/libkolab/lib/kolab_format_file.php
index f5b153b..5f73bf1 100644
--- a/plugins/libkolab/lib/kolab_format_file.php
+++ b/plugins/libkolab/lib/kolab_format_file.php
@@ -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()));
}
/**
diff --git a/plugins/libkolab/lib/kolab_format_journal.php b/plugins/libkolab/lib/kolab_format_journal.php
index b9a1b4f..f7ccd31 100644
--- a/plugins/libkolab/lib/kolab_format_journal.php
+++ b/plugins/libkolab/lib/kolab_format_journal.php
@@ -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()));
}
/**
diff --git a/plugins/libkolab/lib/kolab_format_note.php b/plugins/libkolab/lib/kolab_format_note.php
index 466c536..04a8421 100644
--- a/plugins/libkolab/lib/kolab_format_note.php
+++ b/plugins/libkolab/lib/kolab_format_note.php
@@ -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()));
}
/**
diff --git a/plugins/libkolab/lib/kolab_format_task.php b/plugins/libkolab/lib/kolab_format_task.php
index 56f22dc..a15cb0b 100644
--- a/plugins/libkolab/lib/kolab_format_task.php
+++ b/plugins/libkolab/lib/kolab_format_task.php
@@ -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()));
}
/**