Skip to content

Commit

Permalink
ws/cs/phpdoc
Browse files Browse the repository at this point in the history
  • Loading branch information
mrubinsk committed Jun 5, 2015
1 parent 006d4ca commit 20250fe
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 29 deletions.
Expand Up @@ -86,12 +86,13 @@ public function setLogger(Horde_Log_Logger $logger)
}

/**
* Synchronize the preferences information with the information from the
* backend.
* Synchronize any changes with the History driver.
*
* @param array $params Additional parameters:
* - changes: (array) An array of arrays keyed by backend id containing
* information about each change.
* information about each change. If not present,
* triggers a full history sync.
* - is_reset: (boolean) If true, indicates that UIDVALIDITY changed.
*/
public function synchronize($params = array())
{
Expand All @@ -112,7 +113,6 @@ public function synchronize($params = array())
if (empty($prefix)) {
return;
}

$this->_logger->debug(sprintf(
'History: Incremental update for user: %s, folder: %s, prefix: %s',
$user, $folder, $prefix)
Expand All @@ -122,6 +122,7 @@ public function synchronize($params = array())
foreach ($added as $bid => $object) {
$this->_updateLog($prefix.$object['uid'], $bid);
}

foreach ($deleted as $bid => $object_uid) {
// Check if the object is really gone from the folder.
// Otherwise we just deleted a duplicated object or updated the original one.
Expand All @@ -138,45 +139,41 @@ public function synchronize($params = array())
$bid, $object_uid)
);
$this->_history->log(
$prefix.$object_uid, array('action' => 'delete', 'bid' => $bid), true
$prefix . $object_uid, array('action' => 'delete', 'bid' => $bid), true
);
}
} else {
// Full sync. Either our timestamp is too old or the IMAP
// uidvalidity changed.
$prefix = $this->_constructHistoryPrefix();
if (empty($prefix)) {
return;
}

$this->_logger->debug(sprintf(
'History: Full history sync for user: %s, folder: %s, is_reset: %d, prefix: %s',
$user, $folder, $is_reset, $prefix)
);

// Full sync. Either our timestamp is too old
// or the IMAP uidvalidity changed
$this->_completeSynchronization($prefix, $is_reset);
}
}

/**
* Perform a complete synchronization.
* Also markes stale history entries as 'deleted'.
* Also marks stale history entries as 'deleted'.
*
* @param string $prefix Horde_History prefix
* @param boolean $is_reset Flag to indicate if the UIDVALIDITY changed
*
* @return NULL
* @param string $prefix Horde_History prefix
* @param boolean $is_reset Flag to indicate if the UIDVALIDITY changed
*/
private function _completeSynchronization($prefix, $is_reset)
protected function _completeSynchronization($prefix, $is_reset)
{
$seen_objects = array();
foreach ($this->_data->getObjectToBackend() as $object => $bid) {
$full_id = $prefix.$object;
$full_id = $prefix . $object;
$this->_updateLog($full_id, $bid, $is_reset);
$seen_objects[$full_id] = true;
}

// cut of last ':'
// cut off last ':'
$search_prefix = substr($prefix, 0, -1);

// clean up history database: Mark stale entries as deleted
Expand Down Expand Up @@ -247,15 +244,15 @@ private function _constructHistoryPrefix()
return '';
}

$this->_prefix = $app.':'.$share_id.':';
$this->_prefix = $app . ':' . $share_id . ':';

return $this->_prefix;
}

/**
* Map Kolab object type to horde application name.
*
* @param string $type Kolab object type
* @param string $type Kolab object type
*
* @return string The horde application name. Empty string if unknown
*/
Expand All @@ -277,14 +274,11 @@ private function _type2app($type)
/**
* Update the history log for an object.
*
* @param string $object The object ID.
* @param string $bid The backend ID of
* the object.
* @param bool $force Force update
*
* @return NULL
* @param string $object The object ID.
* @param string $bid The backend ID of the object.
* @param boolean $force Force update
*/
private function _updateLog($object, $bid, $force=false)
protected function _updateLog($object, $bid, $force = false)
{
$last = $this->_history->getLatestEntry($object);
if ($last === false) {
Expand Down Expand Up @@ -321,4 +315,5 @@ private function _updateLog($object, $bid, $force=false)
}
}
}

}
Expand Up @@ -39,8 +39,6 @@ class Horde_Kolab_Storage_Data_Query_History_Cache
* - last_sync: (integer) Timestamp containing the time of last sync.
* - changes: (array) An array of arrays keyed by backend id
* containing information about each change.
*
* @return NULL
*/
public function synchronize($params = array())
{
Expand Down Expand Up @@ -80,4 +78,5 @@ public function synchronize($params = array())
);
}
}

}
Expand Up @@ -384,7 +384,7 @@ public function testModify()
$object = $data->getObject('UID');
$this->assertEquals('modified', $object['summary']);
}

public function testDuplicatesAddedObjects()
{
$data = $this->getMessageStorage()->getData('INBOX/Notes');
Expand Down

0 comments on commit 20250fe

Please sign in to comment.