Always fetch xml from IMAP and parse objects on select

Temporarily we still store data and xml as before, but do not use them on select.
This commit is contained in:
Aleksander Machniak 2018-12-19 12:25:39 +01:00
parent 73e9463595
commit 67f6ef9bbf
2 changed files with 6 additions and 40 deletions

View file

@ -679,7 +679,6 @@ class kolab_storage_cache
return $result;
}
/**
* Get number of objects mathing the given query
*
@ -897,44 +896,10 @@ class kolab_storage_cache
*/
protected function _unserialize($sql_arr)
{
// check if data is a base64-encoded string, for backward compat.
if (strpos(substr($sql_arr['data'], 0, 64), ':') === false) {
$sql_arr['data'] = base64_decode($sql_arr['data']);
}
$object = unserialize($sql_arr['data']);
// de-serialization failed
if ($object === false) {
rcube::raise_error(array(
'code' => 900, 'type' => 'php',
'message' => "Malformed data for {$this->resource_uri}/{$sql_arr['msguid']} object."
), true);
return null;
}
// decode binary properties
foreach ($this->binary_items as $key => $regexp) {
if (!empty($object[$key]) && preg_match($regexp, $sql_arr['xml'], $m)) {
$object[$key] = base64_decode($m[1]);
}
}
$object_type = $sql_arr['type'] ?: $this->folder->type;
$format_type = $this->folder->type == 'configuration' ? 'configuration' : $object_type;
// add meta data
$object['_type'] = $object_type;
$object['_msguid'] = $sql_arr['msguid'];
$object['_mailbox'] = $this->folder->name;
$object['_size'] = strlen($sql_arr['xml']);
$object['_formatobj'] = kolab_format::factory($format_type, 3.0, $sql_arr['xml']);
// Fix old broken objects with missing creation date
if (empty($object['created']) && method_exists($object['_formatobj'], 'to_array')) {
$new_object = $object['_formatobj']->to_array();
$object['created'] = $new_object['created'];
// Fetch object xml
if ($object = $this->folder->read_object($sql_arr['msguid'])) {
// additional meta data
$object['_size'] = strlen($xml);
}
return $object;

View file

@ -486,8 +486,9 @@ class kolab_storage_folder extends kolab_storage_folder_api
$content_type = kolab_format::KTYPE_PREFIX . $object_type;
// check object type header and abort on mismatch
if ($type != '*' && $object_type != $type)
if ($type != '*' && strpos($object_type, $type) !== 0) {
return false;
}
$attachments = array();