Commit 004c6092 authored by Sebastian Kummer's avatar Sebastian Kummer

Merging in latest from upstream (ZP/z-push:refs/heads/develop)

* commit '286d4693':
  ZP-853 Allow a return value of false for single folders when calling Backend->GetFolderStat(). In this case, in Sync the exporter will always run for these folders. In Ping the initial checkup (generate fake changes and force a Sync on this folder if the stat does not match or expired) can not be executed.
  ZP-856 Remove while(1)s.
parents fa73d82d 286d4693
......@@ -518,7 +518,8 @@ class SyncCollections implements Iterator {
}
// check if the folder stat changed since the last sync, if so generate a change for it (only on first run)
if ($this->waitingTime == 0 && ZPush::GetBackend()->HasFolderStats() && $spa->IsExporterRunRequired(ZPush::GetBackend()->GetFolderStat($store, $spa->GetFolderId()), true)) {
$currentFolderStat = ZPush::GetBackend()->GetFolderStat($store, $spa->GetFolderId());
if ($this->waitingTime == 0 && ZPush::GetBackend()->HasFolderStats() && $currentFolderStat !== false && $spa->IsExporterRunRequired($currentFolderStat, true)) {
$this->changes[$spa->GetFolderId()] = 1;
}
}
......
......@@ -287,10 +287,17 @@ class SyncParameters extends StateObject {
* @return boolean
*/
public function IsExporterRunRequired($currentFolderStat, $doLog = false) {
// if the backend returned false as folderstat, we have to run the exporter
if ($currentFolderStat === false) {
$run = true;
}
else {
// check if the folderstat differs from the saved one or expired
$run = ! ($this->HasFolderStat() && $currentFolderStat === $this->GetFolderStat() && time() < $this->GetFolderStatTimeout());
}
if ($doLog) {
$expDate = ($this->HasFolderStatTimeout()) ? date('Y-m-d H:i:s', $this->GetFolderStatTimeout()) : "not set";
ZLog::Write(LOGLEVEL_DEBUG, sprintf("SyncParameters->IsExporterRunRequired(): %s - current: %s - saved: %s - expiring: %s", Utils::PrintAsString($run), $currentFolderStat, Utils::PrintAsString($this->GetFolderStat()), $expDate));
ZLog::Write(LOGLEVEL_DEBUG, sprintf("SyncParameters->IsExporterRunRequired(): %s - current: %s - saved: %s - expiring: %s", Utils::PrintAsString($run), Utils::PrintAsString($currentFolderStat), Utils::PrintAsString($this->GetFolderStat()), $expDate));
}
return $run;
}
......
......@@ -67,7 +67,8 @@ class GetItemEstimate extends RequestProcessor {
$spastatus = false;
// read the folder properties
while (1) {
WBXMLDecoder::ResetInWhile("getItemEstimateFolders");
while(WBXMLDecoder::InWhile("getItemEstimateFolders")) {
if(self::$decoder->getElementStartTag(SYNC_SYNCKEY)) {
try {
$spa->SetSyncKey(self::$decoder->getElementContent());
......
......@@ -59,7 +59,8 @@ class ItemOperations extends RequestProcessor {
$itemoperations = array();
//ItemOperations can either be Fetch, EmptyFolderContents or Move
while (1) {
WBXMLDecoder::ResetInWhile("itemOperationsActions");
while(WBXMLDecoder::InWhile("itemOperationsActions")) {
//TODO check if multiple item operations are possible in one request
$el = self::$decoder->getElement();
......@@ -182,7 +183,8 @@ class ItemOperations extends RequestProcessor {
if(self::$decoder->getElementStartTag(SYNC_ITEMOPERATIONS_SCHEMA)) {
// read schema tags
while (1) {
WBXMLDecoder::ResetInWhile("itemOperationsSchema");
while(WBXMLDecoder::InWhile("itemOperationsSchema")) {
// TODO save elements
$el = self::$decoder->getElement();
$e = self::$decoder->peek();
......
......@@ -72,7 +72,8 @@ class Settings extends RequestProcessor {
// - DeviceInformation
// - UserInformation
// Each of them should only be once per request. Each property must be processed in order.
while (1) {
WBXMLDecoder::ResetInWhile("settingsMain");
while(WBXMLDecoder::InWhile("settingsMain")) {
$propertyName = "";
if (self::$decoder->getElementStartTag(SYNC_SETTINGS_OOF)) {
$propertyName = SYNC_SETTINGS_OOF;
......
......@@ -760,7 +760,7 @@ class Sync extends RequestProcessor {
if ($setupExporter && self::$backend->HasFolderStats()) {
// check if the folder stats changed -> if not, don't setup the exporter, there are no changes!
$newFolderStat = self::$backend->GetFolderStat(ZPush::GetAdditionalSyncFolderStore($spa->GetFolderId()), $spa->GetFolderId());
if (! $spa->IsExporterRunRequired($newFolderStat, true)) {
if ($newFolderStat !== false && ! $spa->IsExporterRunRequired($newFolderStat, true)) {
$changecount = 0;
$setupExporter = false;
ZLog::Write(LOGLEVEL_DEBUG, "Sync(): Folder stat from the backend indicates that the folder did not change. Exporter will not run.");
......@@ -847,7 +847,7 @@ class Sync extends RequestProcessor {
// Fir AS 14.0+ omit output for folder, if there were no incoming or outgoing changes and no Fetch
if (Request::GetProtocolVersion() >= 14.0 && ! $spa->HasNewSyncKey() && $changecount == 0 && empty($actiondata["fetchids"]) && $status == SYNC_STATUS_SUCCESS &&
! $spa->IsExporterRunRequired($newFolderStat)) {
($newFolderStat === false || ! $spa->IsExporterRunRequired($newFolderStat))) {
ZLog::Write(LOGLEVEL_DEBUG, sprintf("HandleSync: No changes found for %s folder id '%s'. Omitting output.", $spa->GetContentClass(), $spa->GetFolderId()));
continue;
}
......
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