Commit 4223ada1 authored by Sebastian Kummer's avatar Sebastian Kummer

ZP-622 ZPushAdmin and Sync-without-heartbeat should not load the

hierarchy folderdata states.

Released under the Affero GNU General Public License (AGPL) version 3.
parent 5920b258
...@@ -119,17 +119,18 @@ class SyncCollections implements Iterator { ...@@ -119,17 +119,18 @@ class SyncCollections implements Iterator {
* Loads all collections known for the current device * Loads all collections known for the current device
* *
* @param boolean $overwriteLoaded (opt) overwrites Collection with saved state if set to true * @param boolean $overwriteLoaded (opt) overwrites Collection with saved state if set to true
* @param boolean $loadState (opt) indicates if the collection sync state should be loaded, default true * @param boolean $loadState (opt) indicates if the collection sync state should be loaded, default false
* @param boolean $checkPermissions (opt) if set to true each folder will pass * @param boolean $checkPermissions (opt) if set to true each folder will pass
* through a backend->Setup() to check permissions. * through a backend->Setup() to check permissions.
* If this fails a StatusException will be thrown. * If this fails a StatusException will be thrown.
* @param boolean $loadHierarchy (opt) if the hierarchy sync states should be loaded, default false
* *
* @access public * @access public
* @throws StatusException with SyncCollections::ERROR_WRONG_HIERARCHY if permission check fails * @throws StatusException with SyncCollections::ERROR_WRONG_HIERARCHY if permission check fails
* @throws StateInvalidException if the sync state can not be found or relation between states is invalid ($loadState = true) * @throws StateInvalidException if the sync state can not be found or relation between states is invalid ($loadState = true)
* @return boolean * @return boolean
*/ */
public function LoadAllCollections($overwriteLoaded = false, $loadState = false, $checkPermissions = false) { public function LoadAllCollections($overwriteLoaded = false, $loadState = false, $checkPermissions = false, $loadHierarchy = false) {
$this->loadStateManager(); $this->loadStateManager();
// this operation should not remove old state counters // this operation should not remove old state counters
...@@ -146,7 +147,7 @@ class SyncCollections implements Iterator { ...@@ -146,7 +147,7 @@ class SyncCollections implements Iterator {
} }
// load the hierarchy data - there are no permissions to verify so we just set it to false // load the hierarchy data - there are no permissions to verify so we just set it to false
if (! $this->LoadCollection(false, $loadState, false)) if ($loadHierarchy && !$this->LoadCollection(false, $loadState, false))
throw new StatusException("Invalid states found while loading hierarchy data. Forcing hierarchy sync"); throw new StatusException("Invalid states found while loading hierarchy data. Forcing hierarchy sync");
if ($invalidStates) if ($invalidStates)
......
...@@ -65,7 +65,7 @@ class Ping extends RequestProcessor { ...@@ -65,7 +65,7 @@ class Ping extends RequestProcessor {
// Load all collections - do load states and check permissions // Load all collections - do load states and check permissions
try { try {
$sc->LoadAllCollections(true, true, true); $sc->LoadAllCollections(true, true, true, true);
} }
catch (StateInvalidException $siex) { catch (StateInvalidException $siex) {
// if no params are present, indicate to send params, else do hierarchy sync // if no params are present, indicate to send params, else do hierarchy sync
......
...@@ -579,7 +579,7 @@ class Sync extends RequestProcessor { ...@@ -579,7 +579,7 @@ class Sync extends RequestProcessor {
// Load all collections - do not overwrite existing (received!), load states and check permissions // Load all collections - do not overwrite existing (received!), load states and check permissions
try { try {
$sc->LoadAllCollections(false, true, true); $sc->LoadAllCollections(false, true, true, true);
} }
catch (StateInvalidException $siex) { catch (StateInvalidException $siex) {
$status = SYNC_STATUS_INVALIDSYNCKEY; $status = SYNC_STATUS_INVALIDSYNCKEY;
...@@ -605,7 +605,7 @@ class Sync extends RequestProcessor { ...@@ -605,7 +605,7 @@ class Sync extends RequestProcessor {
if (!$sc->HasCollections()) if (!$sc->HasCollections())
$status = SYNC_STATUS_SYNCREQUESTINCOMPLETE; $status = SYNC_STATUS_SYNCREQUESTINCOMPLETE;
} }
else { else if (isset($hbinterval)) {
// load the hierarchy data - there are no permissions to verify so we just set it to false // load the hierarchy data - there are no permissions to verify so we just set it to false
if (!$sc->LoadCollection(false, true, false)) { if (!$sc->LoadCollection(false, true, false)) {
$status = SYNC_STATUS_FOLDERHIERARCHYCHANGED; $status = SYNC_STATUS_FOLDERHIERARCHYCHANGED;
......
...@@ -106,8 +106,8 @@ class ZPushAdmin { ...@@ -106,8 +106,8 @@ class ZPushAdmin {
$sc = new SyncCollections(); $sc = new SyncCollections();
$sc->SetStateManager($stateManager); $sc->SetStateManager($stateManager);
// load all collections of device without loading states or checking permissions // load all collections of device without loading states, checking permissions or loading the hierarchy
$sc->LoadAllCollections(true, false, false); $sc->LoadAllCollections(true, false, false, false);
if ($sc->GetLastSyncTime()) if ($sc->GetLastSyncTime())
$device->SetLastSyncTime($sc->GetLastSyncTime()); $device->SetLastSyncTime($sc->GetLastSyncTime());
......
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