Commit 6e7e6594 authored by Sebastian Kummer's avatar Sebastian Kummer

Merge pull request #175 in ZP/z-push from bugfix/ZP-858-ping-hierarchy-checks-old-states to develop

* commit 'f7fbe8e6':
  ZP-858 Ping fully reloads the hierarchy data before verifying hierarchy notifications, Ping has to wait before verifying to give other processes time to write all pending states.
parents 286d4693 f7fbe8e6
...@@ -936,8 +936,9 @@ class BackendZarafa implements IBackend, ISearchProvider { ...@@ -936,8 +936,9 @@ class BackendZarafa implements IBackend, ISearchProvider {
if (!empty($hierarchyNotifications)) { if (!empty($hierarchyNotifications)) {
$hash = $this->getHierarchyHash(); $hash = $this->getHierarchyHash();
if ($hash !== $this->changesSinkHierarchyHash) { if ($hash !== $this->changesSinkHierarchyHash) {
ZLog::Write(LOGLEVEL_DEBUG, sprintf("BackendZarafa->ChangesSink() Hierarchy notification, pending validation. HierarchyHash: %s", $hash)); ZLog::Write(LOGLEVEL_DEBUG, sprintf("BackendZarafa->ChangesSink() Hierarchy notification, pending validation. New hierarchyHash: %s", $hash));
$notifications[] = IBackend::HIERARCHYNOTIFICATION; $notifications[] = IBackend::HIERARCHYNOTIFICATION;
$this->changesSinkHierarchyHash = $hash;
} }
} }
return $notifications; return $notifications;
......
...@@ -129,15 +129,17 @@ class StateManager { ...@@ -129,15 +129,17 @@ class StateManager {
/** /**
* Returns a folder state (SyncParameters) for a folder id * Returns a folder state (SyncParameters) for a folder id
* *
* @param $folderid * @param string $folderid
* @param boolean $fromCacheIfAvailable if set to false, the folderdata is always reloaded, default: true
* *
* @access public * @access public
* @return SyncParameters * @return SyncParameters
*/ */
public function GetSynchedFolderState($folderid) { public function GetSynchedFolderState($folderid, $fromCacheIfAvailable = true) {
// new SyncParameters are cached // new SyncParameters are cached
if (isset($this->synchedFolders[$folderid])) if ($fromCacheIfAvailable && isset($this->synchedFolders[$folderid])) {
return $this->synchedFolders[$folderid]; return $this->synchedFolders[$folderid];
}
$uuid = $this->device->GetFolderUUID($folderid); $uuid = $this->device->GetFolderUUID($folderid);
if ($uuid) { if ($uuid) {
......
...@@ -175,7 +175,7 @@ class SyncCollections implements Iterator { ...@@ -175,7 +175,7 @@ class SyncCollections implements Iterator {
try { try {
// Get SyncParameters for the folder from the state // Get SyncParameters for the folder from the state
$spa = $this->stateManager->GetSynchedFolderState($folderid); $spa = $this->stateManager->GetSynchedFolderState($folderid, !$loadState);
// TODO remove resync of folders for < Z-Push 2 beta4 users // TODO remove resync of folders for < Z-Push 2 beta4 users
// this forces a resync of all states previous to Z-Push 2 beta4 // this forces a resync of all states previous to Z-Push 2 beta4
...@@ -581,6 +581,8 @@ class SyncCollections implements Iterator { ...@@ -581,6 +581,8 @@ class SyncCollections implements Iterator {
foreach ($notifications as $folderid) { foreach ($notifications as $folderid) {
// Check hierarchy notifications // Check hierarchy notifications
if ($folderid === IBackend::HIERARCHYNOTIFICATION) { if ($folderid === IBackend::HIERARCHYNOTIFICATION) {
// wait two seconds before validating this notification, because it could potentially be made by the mobile and we need some time to update the states.
sleep(2);
// check received hierarchy notifications by exporting // check received hierarchy notifications by exporting
if ($this->countHierarchyChange(true)) if ($this->countHierarchyChange(true))
throw new StatusException("SyncCollections->CheckForChanges(): HierarchySync required.", self::HIERARCHY_CHANGED); throw new StatusException("SyncCollections->CheckForChanges(): HierarchySync required.", self::HIERARCHY_CHANGED);
...@@ -718,6 +720,10 @@ class SyncCollections implements Iterator { ...@@ -718,6 +720,10 @@ class SyncCollections implements Iterator {
$changecount = false; $changecount = false;
if ($exportChanges || $this->hierarchyExporterChecked === false) { if ($exportChanges || $this->hierarchyExporterChecked === false) {
try { try {
// if this is a validation (not first run), make sure to load the hierarchy data again
if ($this->hierarchyExporterChecked === true && !$this->LoadCollection(false, true, false))
throw new StatusException("Invalid states found while re-loading hierarchy data.");
// reset backend to the main store // reset backend to the main store
ZPush::GetBackend()->Setup(false); ZPush::GetBackend()->Setup(false);
$changesMem = ZPush::GetDeviceManager()->GetHierarchyChangesWrapper(); $changesMem = ZPush::GetDeviceManager()->GetHierarchyChangesWrapper();
......
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