Check existance of Configuration::customProperties() before calling it (#3125)

This commit is contained in:
Thomas Bruederli 2014-06-02 23:27:44 +02:00
parent 26767a1669
commit a84eb35f01

View file

@ -415,7 +415,7 @@ abstract class kolab_format
$this->obj->setLastModified(self::get_datetime($object['changed'])); $this->obj->setLastModified(self::get_datetime($object['changed']));
// Save custom properties of the given object // Save custom properties of the given object
if (isset($object['x-custom'])) { if (isset($object['x-custom']) && method_exists($this->obj, 'setCustomProperties')) {
$vcustom = new vectorcs; $vcustom = new vectorcs;
foreach ((array)$object['x-custom'] as $cp) { foreach ((array)$object['x-custom'] as $cp) {
if (is_array($cp)) if (is_array($cp))
@ -423,7 +423,8 @@ abstract class kolab_format
} }
$this->obj->setCustomProperties($vcustom); $this->obj->setCustomProperties($vcustom);
} }
else { // load custom properties from XML for caching (#2238) // load custom properties from XML for caching (#2238) if method exists (#3125)
else if (method_exists($this->obj, 'customProperties')) {
$object['x-custom'] = array(); $object['x-custom'] = array();
$vcustom = $this->obj->customProperties(); $vcustom = $this->obj->customProperties();
for ($i=0; $i < $vcustom->size(); $i++) { for ($i=0; $i < $vcustom->size(); $i++) {
@ -456,10 +457,12 @@ abstract class kolab_format
} }
// read custom properties // read custom properties
$vcustom = $this->obj->customProperties(); if (method_exists($this->obj, 'customProperties')) {
for ($i=0; $i < $vcustom->size(); $i++) { $vcustom = $this->obj->customProperties();
$cp = $vcustom->get($i); for ($i=0; $i < $vcustom->size(); $i++) {
$object['x-custom'][] = array($cp->identifier, $cp->value); $cp = $vcustom->get($i);
$object['x-custom'][] = array($cp->identifier, $cp->value);
}
} }
// merge with additional data, e.g. attachments from the message // merge with additional data, e.g. attachments from the message