From da5e6a6023b33c51a10f335317ca8b4e18af1e2b Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Wed, 13 Jan 2010 19:15:54 +0000 Subject: [PATCH 1/8] When Twitter bridge encounters a 403 (rate limit) err, drop the notice instead of requeuing. --- plugins/TwitterBridge/twitter.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/plugins/TwitterBridge/twitter.php b/plugins/TwitterBridge/twitter.php index e133ce6f74..33dfb788bf 100644 --- a/plugins/TwitterBridge/twitter.php +++ b/plugins/TwitterBridge/twitter.php @@ -269,19 +269,23 @@ function process_error($e, $flink, $notice) common_log(LOG_WARNING, $logmsg); - if ($code == 401) { - + switch($code) { + case 401: // Probably a revoked or otherwise bad access token - nuke! - remove_twitter_link($flink); return true; - - } else { + break; + case 403: + // User has exceeder her rate limit -- toss the notice + return true; + break; + default: // For every other case, it's probably some flakiness so try // sending the notice again later (requeue). return false; + break; } } From ec873922e3af7efd1aa6d26ea19c90999f9961b3 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Wed, 13 Jan 2010 20:11:00 -0800 Subject: [PATCH 2/8] Gracefully skip missing user entries when initializing inboxes in bulk --- scripts/initializeinbox.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/initializeinbox.php b/scripts/initializeinbox.php index bc31cba153..5ae9f7d036 100644 --- a/scripts/initializeinbox.php +++ b/scripts/initializeinbox.php @@ -72,7 +72,7 @@ try { foreach ($ids as $id) { $user = User::staticGet('id', $id); if (empty($user)) { - throw new Exception("Can't find user with id '$id'."); + print "Can't find user with id '$id'.\n"; } initializeInbox($user); } From 82f2fe8cca3914ad2a962855951be226141a9d78 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Wed, 13 Jan 2010 20:30:42 -0800 Subject: [PATCH 3/8] in case we have cached 'fake' inboxes, make sure we rebuild them running initializeinbox.php --- scripts/initializeinbox.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/scripts/initializeinbox.php b/scripts/initializeinbox.php index 5ae9f7d036..781179401c 100644 --- a/scripts/initializeinbox.php +++ b/scripts/initializeinbox.php @@ -93,6 +93,12 @@ function initializeInbox($user) $inbox = Inbox::staticGet('user_id', $user_id); + if ($inbox && !empty($inbox->fake)) { + if (!have_option('q', 'quiet')) { + echo "(replacing faux cached inbox)"; + } + $inbox = false; + } if (!empty($inbox)) { if (!have_option('q', 'quiet')) { print "SKIP\n"; From 35a2f8de4d46c403d6ca17695a8d040f003125c8 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Wed, 13 Jan 2010 20:46:44 -0800 Subject: [PATCH 4/8] actually use the user id instead of 0 ;) --- scripts/initializeinbox.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/initializeinbox.php b/scripts/initializeinbox.php index 781179401c..44508fe22a 100644 --- a/scripts/initializeinbox.php +++ b/scripts/initializeinbox.php @@ -91,7 +91,7 @@ function initializeInbox($user) print "Initializing inbox for $user->nickname..."; } - $inbox = Inbox::staticGet('user_id', $user_id); + $inbox = Inbox::staticGet('user_id', $user->id); if ($inbox && !empty($inbox->fake)) { if (!have_option('q', 'quiet')) { @@ -104,7 +104,7 @@ function initializeInbox($user) print "SKIP\n"; } } else { - $inbox = Inbox::initialize($user_id); + $inbox = Inbox::initialize($user->id); if (!have_option('q', 'quiet')) { if (empty($inbox)) { print "ERR\n"; From b25deaacea75f2e565a58ea14aca19627f5cfa93 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Wed, 13 Jan 2010 21:24:02 -0800 Subject: [PATCH 5/8] queue daemon fixes: path fix for xmpp, suppress warning in memcached init --- lib/xmppmanager.php | 2 +- plugins/MemcachePlugin.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/xmppmanager.php b/lib/xmppmanager.php index 9662e97d15..0839cda57a 100644 --- a/lib/xmppmanager.php +++ b/lib/xmppmanager.php @@ -81,7 +81,7 @@ class XmppManager extends IoManager parent::start($master); $this->switchSite(); - require_once "lib/jabber.php"; + require_once INSTALLDIR . "/lib/jabber.php"; # Low priority; we don't want to receive messages diff --git a/plugins/MemcachePlugin.php b/plugins/MemcachePlugin.php index fbc2802f78..bc7fd90765 100644 --- a/plugins/MemcachePlugin.php +++ b/plugins/MemcachePlugin.php @@ -166,7 +166,7 @@ class MemcachePlugin extends Plugin if (is_array($this->servers)) { foreach ($this->servers as $server) { - list($host, $port) = explode(';', $server); + list($host, $port) = @explode(';', $server); if (empty($port)) { $port = 11211; } From 4b839cfc53d1aa5aa64adb940e122efe1475c9e9 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Wed, 13 Jan 2010 21:35:47 -0800 Subject: [PATCH 6/8] fix for non-% memory soft limit --- lib/iomaster.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/iomaster.php b/lib/iomaster.php index aff5b145c2..5d1071a392 100644 --- a/lib/iomaster.php +++ b/lib/iomaster.php @@ -231,7 +231,7 @@ class IoMaster return -1; } } else { - return $this->parseMemoryLimit($limit); + return $this->parseMemoryLimit($softLimit); } return $softLimit; } From abd67452dad9c0e53427731d96de15428a99b086 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Wed, 13 Jan 2010 22:12:19 -0800 Subject: [PATCH 7/8] go straight to the DB for inbox before insert --- classes/Inbox.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/classes/Inbox.php b/classes/Inbox.php index 83cfe8ef82..f3d4afca39 100644 --- a/classes/Inbox.php +++ b/classes/Inbox.php @@ -103,9 +103,9 @@ class Inbox extends Memcached_DataObject static function insertNotice($user_id, $notice_id) { - $inbox = Inbox::staticGet('user_id', $user_id); + $inbox = DB_DataObject::staticGet('inbox', 'user_id', $user_id); - if (empty($inbox) || $inbox->fake) { + if (empty($inbox)) { $inbox = Inbox::initialize($user_id); } From 16742d0fde811256c386d1bae9768fcd939b9af8 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Wed, 13 Jan 2010 22:32:17 -0800 Subject: [PATCH 8/8] do since_id and max_id in inbox --- classes/Inbox.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/classes/Inbox.php b/classes/Inbox.php index f3d4afca39..312b4586b4 100644 --- a/classes/Inbox.php +++ b/classes/Inbox.php @@ -153,8 +153,19 @@ class Inbox extends Memcached_DataObject $ids = unpack('N*', $inbox->notice_ids); - // XXX: handle since_id - // XXX: handle max_id + if (!empty($since_id)) { + $i = array_search($since_id, $ids); + if ($i !== false) { + $ids = array_slice($ids, 0, $i - 1); + } + } + + if (!empty($max_id)) { + $i = array_search($max_id, $ids); + if ($i !== false) { + $ids = array_slice($ids, $i - 1); + } + } $ids = array_slice($ids, $offset, $limit);