Fast-mode for events/tasks/contacts and some code improvements
This commit is contained in:
parent
e05d7987f6
commit
46af51d315
7 changed files with 48 additions and 9 deletions
|
@ -864,7 +864,10 @@ class kolab_storage_cache
|
|||
}
|
||||
|
||||
if ($object['_formatobj']) {
|
||||
$sql_data['xml'] = preg_replace('!(</?[a-z0-9:-]+>)[\n\r\t\s]+!ms', '$1', (string)$object['_formatobj']->write(3.0));
|
||||
$xml = (string) $object['_formatobj']->write(3.0);
|
||||
$size = strlen($xml);
|
||||
|
||||
$sql_data['xml'] = preg_replace('!(</?[a-z0-9:-]+>)[\n\r\t\s]+!ms', '$1', $xml);
|
||||
$sql_data['tags'] = ' ' . join(' ', $object['_formatobj']->get_tags()) . ' '; // pad with spaces for strict/prefix search
|
||||
$sql_data['words'] = ' ' . join(' ', $object['_formatobj']->get_words()) . ' ';
|
||||
}
|
||||
|
@ -897,6 +900,10 @@ class kolab_storage_cache
|
|||
}
|
||||
}
|
||||
|
||||
if ($size) {
|
||||
$data['_size'] = $size;
|
||||
}
|
||||
|
||||
// use base64 encoding (Bug #1912, #2662)
|
||||
$sql_data['data'] = base64_encode(serialize($data));
|
||||
|
||||
|
@ -911,16 +918,22 @@ class kolab_storage_cache
|
|||
if ($sql_arr['fast-mode'] && !empty($sql_arr['data'])
|
||||
&& ($object = unserialize(base64_decode($sql_arr['data'])))
|
||||
) {
|
||||
$object['uid'] = $sql_arr['uid'];
|
||||
|
||||
foreach ($this->data_props as $prop) {
|
||||
if (!isset($object[$prop]) && isset($sql_arr[$prop])) {
|
||||
$object[$prop] = $sql_arr[$prop];
|
||||
|
||||
if (($prop == 'created' || $prop == 'changed') && $object[$prop] && is_string($object[$prop])) {
|
||||
$object[$prop] = new DateTime($object[$prop]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($sql_arr['created'] && empty($object['created'])) {
|
||||
$object['created'] = new DateTime($sql_arr['created']);
|
||||
}
|
||||
|
||||
if ($sql_arr['changed'] && empty($object['changed'])) {
|
||||
$object['changed'] = new DateTime($sql_arr['changed']);
|
||||
}
|
||||
|
||||
$object['_type'] = $sql_arr['type'] ?: $this->folder->type;
|
||||
$object['_msguid'] = $sql_arr['msguid'];
|
||||
$object['_mailbox'] = $this->folder->name;
|
||||
|
|
|
@ -25,7 +25,7 @@ class kolab_storage_cache_contact extends kolab_storage_cache
|
|||
{
|
||||
protected $extra_cols_max = 255;
|
||||
protected $extra_cols = array('type', 'name', 'firstname', 'surname', 'email');
|
||||
protected $data_props = array('type', 'name', 'firstname', 'middlename', 'prefix', 'suffix', 'surname', 'email', 'organization', 'uid');
|
||||
protected $data_props = array('type', 'name', 'firstname', 'middlename', 'prefix', 'suffix', 'surname', 'email', 'organization');
|
||||
protected $binary_items = array(
|
||||
'photo' => '|<photo><uri>[^;]+;base64,([^<]+)</uri></photo>|i',
|
||||
'pgppublickey' => '|<key><uri>data:application/pgp-keys;base64,([^<]+)</uri></key>|i',
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
class kolab_storage_cache_event extends kolab_storage_cache
|
||||
{
|
||||
protected $extra_cols = array('dtstart','dtend');
|
||||
protected $data_props = array('categories', 'status', 'attendees'); // start, end
|
||||
|
||||
/**
|
||||
* Helper method to convert the given Kolab object into a dataset to be written to cache
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
class kolab_storage_cache_file extends kolab_storage_cache
|
||||
{
|
||||
protected $extra_cols = array('filename');
|
||||
protected $data_props = array('type', 'size', 'filename', 'fileid', 'uid');
|
||||
protected $data_props = array('type', 'size', 'filename', 'fileid');
|
||||
|
||||
/**
|
||||
* Helper method to convert the given Kolab object into a dataset to be written to cache
|
||||
|
@ -51,4 +51,27 @@ class kolab_storage_cache_file extends kolab_storage_cache
|
|||
|
||||
return $sql_data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to turn stored cache data into a valid storage object
|
||||
*
|
||||
* @override
|
||||
*/
|
||||
protected function _unserialize($sql_arr)
|
||||
{
|
||||
$object = parent::_unserialize($sql_arr);
|
||||
|
||||
if ($object && $sql_arr['fast-mode']) {
|
||||
if (!empty($object['_attachments'])) {
|
||||
$file = $object['_attachments'][key($object['_attachments'])];
|
||||
|
||||
$object['type'] = $file['mimetype'];
|
||||
$object['size'] = $file['size'];
|
||||
$object['fileid'] = $file['id'];
|
||||
$object['filename'] = $file['name'];
|
||||
}
|
||||
}
|
||||
|
||||
return $object;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
class kolab_storage_cache_journal extends kolab_storage_cache
|
||||
{
|
||||
protected $extra_cols = array('dtstart','dtend');
|
||||
protected $data_props = array('categories');
|
||||
|
||||
/**
|
||||
* Helper method to convert the given Kolab object into a dataset to be written to cache
|
||||
|
|
|
@ -23,5 +23,5 @@
|
|||
|
||||
class kolab_storage_cache_note extends kolab_storage_cache
|
||||
{
|
||||
protected $data_props = array('uid', 'title', 'created', 'changed');
|
||||
protected $data_props = array('title');
|
||||
}
|
|
@ -23,7 +23,8 @@
|
|||
|
||||
class kolab_storage_cache_task extends kolab_storage_cache
|
||||
{
|
||||
protected $extra_cols = array('dtstart','dtend');
|
||||
protected $extra_cols = array('dtstart', 'dtend');
|
||||
protected $data_props = array('categories', 'status'); // start, due
|
||||
|
||||
/**
|
||||
* Helper method to convert the given Kolab object into a dataset to be written to cache
|
||||
|
|
Loading…
Add table
Reference in a new issue