Commit b2bb1fef authored by Sebastian Kummer's avatar Sebastian Kummer

Merge pull request #154 in ZP/z-push from...

Merge pull request #154 in ZP/z-push from bugfix/ZP-840-ping-loop-if-exporter-state-is-not to develop

* commit 'a1541482':
  ZP-840 Rename exception variable.
  ZP-840 Renamed exception variable.
  ZP-840 Catch StateInvalidException when in partial mode.
  ZP-840 Do not throw StateNotFoundException as this messes up Ping. Just treat it as StateInvalid (which is true, FD indicates a state that is not available), do not catch both types in Ping as only StateInvalidException will be thrown.

(cherry picked from commit abf4c77c)

Conflicts:
	src/lib/core/synccollections.php
	src/lib/request/ping.php
parent ece2e377
......@@ -124,7 +124,7 @@ class SyncCollections implements Iterator {
*
* @access public
* @throws StatusException with SyncCollections::ERROR_WRONG_HIERARCHY if permission check fails
* @throws StateNotFoundException if the sync state can not be found ($loadState = true)
* @throws StateInvalidException if the sync state can not be found or relation between states is invalid ($loadState = true)
* @return boolean
*/
public function LoadAllCollections($overwriteLoaded = false, $loadState = false, $checkPermissions = false) {
......@@ -160,7 +160,7 @@ class SyncCollections implements Iterator {
*
* @access public
* @throws StatusException with SyncCollections::ERROR_WRONG_HIERARCHY if permission check fails
* @throws StateNotFoundException if the sync state can not be found ($loadState = true)
* @throws StateInvalidException if the sync state can not be found or relation between states is invalid ($loadState = true)
* @return boolean
*/
public function LoadCollection($folderid, $loadState = false, $checkPermissions = false) {
......@@ -193,8 +193,18 @@ class SyncCollections implements Iterator {
$addStatus = $this->AddCollection($spa);
// load the latest known syncstate if requested
if ($addStatus && $loadState === true)
$this->addparms[$folderid]["state"] = $this->stateManager->GetSyncState($spa->GetLatestSyncKey());
if ($addStatus && $loadState === true) {
try {
$this->addparms[$folderid]["state"] = $this->stateManager->GetSyncState($spa->GetLatestSyncKey());
}
catch (StateNotFoundException $snfe) {
// if we can't find the state, first we should try a sync of that folder, so
// we generate a fake change, so a sync on this folder is triggered
$this->changes[$folderid] = 1;
return false;
}
}
return $addStatus;
}
......
......@@ -67,23 +67,19 @@ class Ping extends RequestProcessor {
try {
$sc->LoadAllCollections(true, true, true);
}
catch (StateNotFoundException $snfex) {
catch (StateInvalidException $siex) {
// if no params are present, indicate to send params, else do hierarchy sync
if (!$params_present) {
$pingstatus = SYNC_PINGSTATUS_FAILINGPARAMS;
self::$topCollector->AnnounceInformation("StateNotFoundException: require PingParameters", true);
self::$topCollector->AnnounceInformation("StateInvalidException: require PingParameters", true);
}
else {
$pingstatus = SYNC_PINGSTATUS_FOLDERHIERSYNCREQUIRED;
self::$topCollector->AnnounceInformation("StateNotFoundException: require HierarchySync", true);
}
}
catch (StateInvalidException $snfex) {
// we do not have a ping status for this, but SyncCollections should have generated fake changes for the folders which are broken
$fakechanges = $sc->GetChangedFolderIds();
$foundchanges = true;
// we do not have a ping status for this, but SyncCollections should have generated fake changes for the folders which are broken
$fakechanges = $sc->GetChangedFolderIds();
$foundchanges = true;
self::$topCollector->AnnounceInformation("StateInvalidException: force sync", true);
self::$topCollector->AnnounceInformation("StateInvalidException: force sync", true);
}
}
catch (StatusException $stex) {
$pingstatus = SYNC_PINGSTATUS_FOLDERHIERSYNCREQUIRED;
......@@ -235,4 +231,4 @@ class Ping extends RequestProcessor {
return true;
}
}
?>
\ No newline at end of file
?>
......@@ -558,9 +558,9 @@ class Sync extends RequestProcessor {
try {
$sc->LoadAllCollections(false, true, true);
}
catch (StateNotFoundException $snfex) {
catch (StateInvalidException $siex) {
$status = SYNC_STATUS_INVALIDSYNCKEY;
self::$topCollector->AnnounceInformation("StateNotFoundException", true);
self::$topCollector->AnnounceInformation("StateInvalidException", true);
}
catch (StatusException $stex) {
$status = SYNC_STATUS_FOLDERHIERARCHYCHANGED;
......@@ -1282,4 +1282,4 @@ class Sync extends RequestProcessor {
}
}
?>
\ No newline at end of file
?>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment