Skip to content

Commit

Permalink
Break out some common code from initPartialSync
Browse files Browse the repository at this point in the history
  • Loading branch information
mrubinsk committed Feb 18, 2015
1 parent b9dde22 commit b323432
Showing 1 changed file with 42 additions and 9 deletions.
51 changes: 42 additions & 9 deletions framework/ActiveSync/lib/Horde/ActiveSync/Collections.php
Expand Up @@ -731,12 +731,36 @@ public function initFullSync()
*/
public function initPartialSync()
{

// PARTIAL is allowed without a <collection> tag if the
// waitinterval, heartbeat, or windowsize changed. So, short circuit
// the logic for checking for changed collections in this case.
if (empty($this->_collections)) {
// PARTIAL is allowed without a <collection> tag if the
// waitinterval, heartbeat, or windowsize changed.
$this->_logger->err('No collections in collection handler, loading full collection set from cache.');
$this->_collections->loadCollectionsFromCache();
foreach ($this->_collections as $value) {
// Remove keys from confirmed synckeys array and count them
if (isset($value['synckey'])) {
if (isset($this->_cache->confirmed_synckeys[$value['synckey']])) {
$this->_logger->info(sprintf(
'Removed %s from confirmed_synckeys',
$value['synckey'])
);
$this->_cache->removeConfirmedKey($value['synckey']);
$this->_confirmedCount++;
}
$this->_synckeyCount++;
}
}
if (!$this->_checkConfirmedKeys()) {
$this->_logger->err('Some synckeys were not confirmed. Requesting full SYNC');
$this->save();
return false;
}

return true;
}

$this->_tempSyncCache = clone $this->_cache;
$c = $this->_tempSyncCache->getCollections();
foreach ($this->_collections as $key => $value) {
Expand Down Expand Up @@ -800,13 +824,7 @@ public function initPartialSync()
}
}

$csk = $this->_cache->confirmed_synckeys;
if ($csk) {
$this->_logger->info(sprintf(
'[%s] Confirmed Synckeys contains %s',
$this->_procid,
serialize($csk))
);
if (!$this->_checkConfirmedKeys()) {
$this->_logger->err('Some synckeys were not confirmed. Requesting full SYNC');
$this->save();
return false;
Expand All @@ -822,6 +840,21 @@ public function initPartialSync()
return true;
}

protected function _checkConfirmedKeys()
{
$csk = $this->_cache->confirmed_synckeys;
if ($csk) {
$this->_logger->info(sprintf(
'[%s] Confirmed Synckeys contains %s',
$this->_procid,
serialize($csk))
);
return false;
}

return true;
}

/**
* Return if we can do an empty response
*
Expand Down

0 comments on commit b323432

Please sign in to comment.