]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/dbqueuemanager.php
Merge remote-tracking branch 'upstream/nightly' into nightly
[quix0rs-gnu-social.git] / lib / dbqueuemanager.php
index 45c4b694d2e4848237bcae4563461fbb79ab55be..4440a4d93060f826c0a6f8559e2bda4edc3d2f4a 100644 (file)
@@ -72,7 +72,7 @@ class DBQueueManager extends QueueManager
     public function poll()
     {
         //$this->_log(LOG_DEBUG, 'Checking for notices...');
-        $qi = Queue_item::top($this->activeQueues());
+        $qi = Queue_item::top($this->activeQueues(), $this->getIgnoredTransports());
         if (!$qi instanceof Queue_item) {
             //$this->_log(LOG_DEBUG, 'No notices waiting; idling.');
             return false;
@@ -89,17 +89,26 @@ class DBQueueManager extends QueueManager
         $rep = $this->logrep($item);
         $this->_log(LOG_DEBUG, "Got {$rep} for transport {$qi->transport}");
         
-        $handler = $this->getHandler($qi->transport);
-        if ($handler) {
-            if ($handler->handle($item)) {
-                $this->_log(LOG_INFO, "[{$qi->transport}:$rep] Successfully handled item");
-                $this->_done($qi);
-            } else {
-                $this->_log(LOG_INFO, "[{$qi->transport}:$rep] Failed to handle item");
-                $this->_fail($qi);
-            }
-        } else {
+        try {
+            $handler = $this->getHandler($qi->transport);
+            $result = $handler->handle($item);
+        } catch (NoQueueHandlerException $e) {
             $this->noHandlerFound($qi, $rep);
+            return true;
+        } catch (AlreadyFulfilledException $e) {
+            $this->_log(LOG_ERR, "[{$qi->transport}:$rep] AlreadyFulfilledException thrown: {$e->getMessage()}");
+            $result = true;
+        } catch (Exception $e) {
+            $this->_log(LOG_ERR, "[{$qi->transport}:$rep] Exception thrown: {$e->getMessage()}");
+            $result = false;
+        }
+
+        if ($result) {
+            $this->_log(LOG_INFO, "[{$qi->transport}:$rep] Successfully handled item");
+            $this->_done($qi);
+        } else {
+            $this->_log(LOG_INFO, "[{$qi->transport}:$rep] Failed to handle item");
+            $this->_fail($qi);
         }
         return true;
     }