Changeset View
Changeset View
Standalone View
Standalone View
lib/kolab_sync_data.php
Show First 20 Lines • Show All 86 Lines • ▼ Show 20 Lines | abstract class kolab_sync_data implements Syncroton_Data_IData | ||||
/** | /** | ||||
* Internal cache for IMAP folders list | * Internal cache for IMAP folders list | ||||
* | * | ||||
* @var array | * @var array | ||||
*/ | */ | ||||
protected $imap_folders = array(); | protected $imap_folders = array(); | ||||
/** | /** | ||||
* Shortcut to logging. | |||||
*/ | |||||
protected $log; | |||||
/** | |||||
* Timezone | * Timezone | ||||
* | * | ||||
* @var string | * @var string | ||||
*/ | */ | ||||
protected $timezone; | protected $timezone; | ||||
/** | /** | ||||
* List of device types with multiple folders support | * List of device types with multiple folders support | ||||
▲ Show 20 Lines • Show All 78 Lines • ▼ Show 20 Lines | abstract class kolab_sync_data implements Syncroton_Data_IData | ||||
{ | { | ||||
$this->backend = kolab_sync_backend::get_instance(); | $this->backend = kolab_sync_backend::get_instance(); | ||||
$this->device = $device; | $this->device = $device; | ||||
$this->asversion = floatval($device->acsversion); | $this->asversion = floatval($device->acsversion); | ||||
$this->syncTimeStamp = $syncTimeStamp; | $this->syncTimeStamp = $syncTimeStamp; | ||||
$this->defaultRootFolder = $this->defaultFolder . '::Syncroton'; | $this->defaultRootFolder = $this->defaultFolder . '::Syncroton'; | ||||
$this->log = Syncroton_Registry::get('loggerBackend'); | |||||
// set internal timezone of kolab_format to user timezone | // set internal timezone of kolab_format to user timezone | ||||
try { | try { | ||||
$this->timezone = rcube::get_instance()->config->get('timezone', 'GMT'); | $this->timezone = rcube::get_instance()->config->get('timezone', 'GMT'); | ||||
kolab_format::$timezone = new DateTimeZone($this->timezone); | kolab_format::$timezone = new DateTimeZone($this->timezone); | ||||
} | } | ||||
catch (Exception $e) { | catch (Exception $e) { | ||||
//rcube::raise_error($e, true); | //rcube::raise_error($e, true); | ||||
$this->timezone = 'GMT'; | $this->timezone = 'GMT'; | ||||
▲ Show 20 Lines • Show All 752 Lines • ▼ Show 20 Lines | protected function getObject($folderid, $entryid, &$folder = null) | ||||
$uid = $entryid; | $uid = $entryid; | ||||
// See self::serverId() for full explanation | // See self::serverId() for full explanation | ||||
// Use (slower) UID prefix matching... | // Use (slower) UID prefix matching... | ||||
if (preg_match('/^CRC([0-9A-Fa-f]{8})(.+)$/', $uid, $matches)) { | if (preg_match('/^CRC([0-9A-Fa-f]{8})(.+)$/', $uid, $matches)) { | ||||
$crc = $matches[1]; | $crc = $matches[1]; | ||||
$uid = $matches[2]; | $uid = $matches[2]; | ||||
if (strlen($entryid) >= 64) { | |||||
machniak: Did you encounter any issues with this? The point was to not use slower prefix matching query… | |||||
Not Done Inline ActionsI have. vanmeeuwen: I have. | |||||
foreach ($folder->select(array(array('uid', '~*', $uid))) as $object) { | foreach ($folder->select(array(array('uid', '~*', $uid))) as $object) { | ||||
if (($object['uid'] == $uid || strpos($object['uid'], $uid) === 0) | if (($object['uid'] == $uid || strpos($object['uid'], $uid) === 0) | ||||
&& $crc == $this->objectCRC($object['uid'], $folder) | && $crc == $this->objectCRC($object['uid'], $folder) | ||||
) { | ) { | ||||
$object['_folderid'] = $folderid; | $object['_folderid'] = $folderid; | ||||
return $object; | return $object; | ||||
} | } | ||||
} | } | ||||
continue; | continue; | ||||
} | } | ||||
} | |||||
// Or (faster) strict UID matching... | // Or (faster) strict UID matching... | ||||
if (($object = $folder->get_object($uid)) | if (($object = $folder->get_object($uid)) | ||||
&& ($crc === null || $crc == $this->objectCRC($object['uid'], $folder)) | && ($crc === null || $crc == $this->objectCRC($object['uid'], $folder)) | ||||
) { | ) { | ||||
$object['_folderid'] = $folderid; | $object['_folderid'] = $folderid; | ||||
return $object; | return $object; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 966 Lines • Show Last 20 Lines |
Did you encounter any issues with this? The point was to not use slower prefix matching query if we have a non-truncated UID. So, we skip this code and go directly to the $folder->get_object($uid) below.