Page MenuHomePhorge

D5196.1775369885.diff
No OneTemporary

Authored By
Unknown
Size
3 KB
Referenced Files
None
Subscribers
None

D5196.1775369885.diff

diff --git a/lib/ext/Syncroton/Command/Ping.php b/lib/ext/Syncroton/Command/Ping.php
--- a/lib/ext/Syncroton/Command/Ping.php
+++ b/lib/ext/Syncroton/Command/Ping.php
@@ -36,8 +36,24 @@
protected $_skipValidatePolicyKey = true;
protected $_changesDetected = false;
protected $_foldersWithChanges = [];
+ private bool $_testNewFolderCache = false;
private function goToSleep($sleepInterval) {
+ if ($this->_testNewFolderCache) {
+ $this->_testNewFolderCache = false;
+ if ($this->_logger instanceof Zend_Log) {
+ $this->_logger->debug(__METHOD__ . '::' . __LINE__ . ' Testing new folder cache');
+ }
+
+ $metadata = [];
+ $metadata['FOLDER'] = [];
+ $metadata['FOLDER'][$this->_device->deviceid] = [];
+ $metadata['FOLDER'][$this->_device->deviceid]['S'] = '1';
+ $metadata = json_encode($metadata);
+
+ \kolab_sync::get_instance()->get_storage()->set_metadata("NewFolder", ['/private/vendor/kolab/activesync' => $metadata]);
+ return;
+ }
// take a break to save battery lifetime
call_user_func(Syncroton_Registry::getSleepCallback());
sleep($sleepInterval);
@@ -72,6 +88,11 @@
if (isset($xml->HeartbeatInterval)) {
$this->_device->pinglifetime = (int)$xml->HeartbeatInterval;
+ // Magic value for testing
+ if ($this->_device->pinglifetime == 9999) {
+ $this->_testNewFolderCache = true;
+ $this->_device->pinglifetime = 900;
+ }
}
if (isset($xml->Folders->Folder)) {
diff --git a/tests/Sync/PingTest.php b/tests/Sync/PingTest.php
--- a/tests/Sync/PingTest.php
+++ b/tests/Sync/PingTest.php
@@ -229,4 +229,57 @@
$this->assertSame('7', $xpath->query("//ns:Ping/ns:Status")->item(0)->nodeValue);
}
+
+ /**
+ * Test changed subscription while ping is running
+ */
+ public function testNewFolderSubscriptionStateDuringPing()
+ {
+ // $this->markTestSkipped("sdlkjf");
+ //Initialize the folder state
+ $request = <<<EOF
+ <?xml version="1.0" encoding="utf-8"?>
+ <!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/">
+ <FolderSync xmlns="uri:FolderHierarchy">
+ <SyncKey>0</SyncKey>
+ </FolderSync>
+ EOF;
+
+ $response = $this->request($request, 'FolderSync');
+ $this->assertEquals(200, $response->getStatusCode());
+
+ $request = <<<EOF
+ <?xml version="1.0" encoding="utf-8"?>
+ <!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/">
+ <FolderSync xmlns="uri:FolderHierarchy">
+ <SyncKey>1</SyncKey>
+ </FolderSync>
+ EOF;
+
+ $response = $this->request($request, 'FolderSync');
+ $this->assertEquals(200, $response->getStatusCode());
+
+ $request = <<<EOF
+ <?xml version="1.0" encoding="utf-8"?>
+ <!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/">
+ <Ping xmlns="uri:Ping">
+ <HeartbeatInterval>9999</HeartbeatInterval>
+ <Folders>
+ <Folder>
+ <Id>38b950ebd62cd9a66929c89615d0fc04</Id>
+ <Class>Email</Class>
+ </Folder>
+ </Folders>
+ </Ping>
+ EOF;
+
+ $response = $this->request($request, 'Ping');
+
+ $this->assertEquals(200, $response->getStatusCode());
+
+ $dom = $this->fromWbxml($response->getBody());
+ $xpath = $this->xpath($dom);
+
+ $this->assertSame('7', $xpath->query("//ns:Ping/ns:Status")->item(0)->nodeValue);
+ }
}

File Metadata

Mime Type
text/plain
Expires
Sun, Apr 5, 6:18 AM (23 h, 54 m ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18832615
Default Alt Text
D5196.1775369885.diff (3 KB)

Event Timeline