]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Wrap each bit of distrib queue handler's saving operation in a try/catch; log excepti...
authorBrion Vibber <brion@pobox.com>
Fri, 29 Jan 2010 06:26:58 +0000 (22:26 -0800)
committerBrion Vibber <brion@pobox.com>
Fri, 29 Jan 2010 06:26:58 +0000 (22:26 -0800)
lib/distribqueuehandler.php

index f458d238da97c77cdd6006ee821de09ab361c36b..4477468d0a38d523c26163b3afcc987805bf3617 100644 (file)
@@ -62,23 +62,60 @@ class DistribQueueHandler
     {
         // XXX: do we need to change this for remote users?
 
-        $notice->saveTags();
+        try {
+            $notice->saveTags();
+        } catch (Exception $e) {
+            $this->logit($notice, $e);
+        }
 
-        $groups = $notice->saveGroups();
+        try {
+            $groups = $notice->saveGroups();
+        } catch (Exception $e) {
+            $this->logit($notice, $e);
+        }
 
-        $recipients = $notice->saveReplies();
+        try {
+            $recipients = $notice->saveReplies();
+        } catch (Exception $e) {
+            $this->logit($notice, $e);
+        }
 
-        $notice->addToInboxes($groups, $recipients);
+        try {
+            $notice->addToInboxes($groups, $recipients);
+        } catch (Exception $e) {
+            $this->logit($notice, $e);
+        }
 
-        $notice->saveUrls();
+        try {
+            $notice->saveUrls();
+        } catch (Exception $e) {
+            $this->logit($notice, $e);
+        }
 
-        Event::handle('EndNoticeSave', array($notice));
+        try {
+            Event::handle('EndNoticeSave', array($notice));
+            // Enqueue for other handlers
+        } catch (Exception $e) {
+            $this->logit($notice, $e);
+        }
 
-        // Enqueue for other handlers
-
-        common_enqueue_notice($notice);
+        try {
+            common_enqueue_notice($notice);
+        } catch (Exception $e) {
+            $this->logit($notice, $e);
+        }
 
         return true;
     }
+    
+    protected function logit($notice, $e)
+    {
+        common_log(LOG_ERR, "Distrib queue exception saving notice $notice->id: " .
+            $e->getMessage() . ' ' .
+            str_replace("\n", " ", $e->getTraceAsString()));
+
+        // We'll still return true so we don't get stuck in a loop
+        // trying to run a bad insert over and over...
+    }
 }