]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/YammerImport/lib/yammerqueuehandler.php
Made YammerImport more robust against errors; can now pause/resume/reset the import...
[quix0rs-gnu-social.git] / plugins / YammerImport / lib / yammerqueuehandler.php
index acc807311566ee8c0ff0eb4c496d190b4868bdd7..0c4e8aec1d00a78e3da4d7191623d0244a506812 100644 (file)
@@ -38,21 +38,24 @@ class YammerQueueHandler extends QueueHandler
     {
         $runner = YammerRunner::init();
         if ($runner->hasWork()) {
-            if ($runner->iterate()) {
-                if ($runner->hasWork()) {
-                    // More to do? Shove us back on the queue...
-                    $runner->startBackgroundImport();
+            try {
+                if ($runner->iterate()) {
+                    if ($runner->hasWork()) {
+                        // More to do? Shove us back on the queue...
+                        $runner->startBackgroundImport();
+                    }
+                }
+            } catch (Exception $e) {
+                try {
+                    $runner->recordError($e->getMessage());
+                } catch (Exception $f) {
+                    common_log(LOG_ERR, "Error while recording error in Yammer background import: " . $e->getMessage() . " " . $f->getMessage());
                 }
-                return true;
-            } else {
-                // Something failed?
-                // @fixme should we be trying again here, or should we give warning?
-                return false;
             }
         } else {
             // We're done!
             common_log(LOG_INFO, "Yammer import has no work to do at this time; discarding.");
-            return true;
         }
+        return true;
     }
 }