added retry if caldav request failed
authorPaul Mehrer <p.mehrer@metaways.de>
Thu, 24 Jul 2014 10:43:03 +0000 (12:43 +0200)
committerPhilipp Schüle <p.schuele@metaways.de>
Thu, 4 Sep 2014 09:26:37 +0000 (11:26 +0200)
Change-Id: I8428a8c454f749936e2a1959e11db47540a10982
Reviewed-on: http://gerrit.tine20.com/customers/895
Tested-by: Jenkins CI (http://ci.tine20.com/)
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
tine20/Tinebase/Import/CalDav/Client.php

index ccff162..b1bfb15 100644 (file)
@@ -136,12 +136,23 @@ class Tinebase_Import_CalDav_Client extends \Sabre\DAV\Client
     }
     
     public function calDavRequest($method, $uri, $body, $depth = 0)
-    {try {
-        $response = $this->request($method, $uri, $body, array(
-            'Depth' => $depth,
-            'Content-Type' => 'text/xml',
-        )); } catch (Exception $e) {
-            echo $method. $uri .$body. $e->getMessage() ."\n\n";throw $e;
+    {
+        $redo = 0;
+        while (++$redo < 4)
+        {
+            try {
+                $response = $this->request($method, $uri, $body, array(
+                    'Depth' => $depth,
+                    'Content-Type' => 'text/xml',
+                ));
+            } catch (Exception $e) {
+                if (Tinebase_Core::isLogLevel(Zend_Log::WARN))
+                    Tinebase_Core::getLogger()->warn(__METHOD__ . '::' . __LINE__ . ' caldav request failed, sleeping 60 seconds and retrying: '
+                            . $method . ' ' . $uri . "\n" . $body . "\n" . $e->getMessage());
+                sleep(60);
+                continue;
+            }
+            break;
         }
         
         $result = $this->parseMultiStatus($response['body']);