Fix redundant updates of private $tags property

This could cause invalid result of get_tags() method after save_tags() use.
This commit is contained in:
Aleksander Machniak 2017-03-31 12:44:57 +02:00
parent 3840ffc5fe
commit 24143cc17e

View file

@ -189,7 +189,7 @@ class kolab_storage_config
$status = $folder->save($object, self::FOLDER_TYPE . '.' . $object['type'], $object['uid']);
// on success, update cached tags list
if ($status && is_array($this->tags)) {
if ($status && $object['category'] == 'tag' && is_array($this->tags)) {
$found = false;
unset($object['_formatobj']); // we don't need it anymore
@ -713,13 +713,11 @@ class kolab_storage_config
}
if ($update) {
if ($this->save($relation, 'relation')) {
$this->tags[$idx] = $relation; // update in-memory cache
}
$this->save($relation, 'relation');
}
if ($selected) {
$tags = array_diff($tags, (array)$relation['name']);
$tags = array_diff($tags, array($relation['name']));
}
}
@ -732,9 +730,7 @@ class kolab_storage_config
'category' => 'tag',
);
if ($this->save($relation, 'relation')) {
$this->tags[] = $relation; // update in-memory cache
}
$this->save($relation, 'relation');
}
}
}