From 42104612bdd33067262c882e3037564e1e35957a Mon Sep 17 00:00:00 2001 From: Marcel van der Boom Date: Thu, 19 Jun 2014 10:36:52 +0200 Subject: [PATCH] Make sure the Attention::saveNew does not cause an exception so queue items get removed It's less of a problem that one queue-item does not get handled, attention wise, than that the queue keeps filling up. The typical error raised here is 'already exists' so it's not even the case that the item won't get handled (it already has been). The real problem is that the queue_item table accepts duplicates (content-wise) which it should not. --- plugins/TwitterBridge/lib/tweetinqueuehandler.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/plugins/TwitterBridge/lib/tweetinqueuehandler.php b/plugins/TwitterBridge/lib/tweetinqueuehandler.php index 79d36d11d5..0ab7480305 100644 --- a/plugins/TwitterBridge/lib/tweetinqueuehandler.php +++ b/plugins/TwitterBridge/lib/tweetinqueuehandler.php @@ -55,7 +55,14 @@ class TweetInQueueHandler extends QueueHandler if ($flink instanceof Foreign_link) { common_log(LOG_DEBUG, "TweetInQueueHandler - Got flink so add notice ". $notice->id." to attentions for user ".$flink->user_id); - Attention::saveNew($notice, $flink->getProfile()); + try { + Attention::saveNew($notice, $flink->getProfile()); + } catch (Exception $e) { + // Log the exception, but make sure we don't bail out, we + // still have a queue item to remove here-after. + common_log(LOG_ERR, "Failed adding notice {$notice->id} to attentions for user {$flink->user_id}: " . + $e->getMessage()); + } } else { common_log(LOG_DEBUG, "TweetInQueueHandler - No flink found for foreign user ".$receiver); } -- 2.39.2