From 9fd2541b528e5575d81e7884e16842144d5674f7 Mon Sep 17 00:00:00 2001 From: Joshua Judson Rosen Date: Sun, 23 Nov 2014 23:24:16 -0500 Subject: [PATCH 1/5] QueueManager: don't assume all non-XML strings are JSON Some of the standard plugins queue simple, unstructured numbers-- e.g.: EmailSummary and OfflineBackup both queue user-IDs. --- lib/queuemanager.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/queuemanager.php b/lib/queuemanager.php index bc18e1fc56..d42e4b4b57 100644 --- a/lib/queuemanager.php +++ b/lib/queuemanager.php @@ -181,7 +181,10 @@ abstract class QueueManager extends IoManager // If it is a string, we really store a JSON object in there // except if it begins with '<', because then it is XML. - if (is_string($object) && substr($object, 0, 1) != '<') { + if (is_string($object) && + substr($object, 0, 1) != '<' && + !is_numeric($object)) + { $json = json_decode($object); if ($json === null) { throw new Exception('Bad frame in queue item'); From 2f506dde28f008c6efd25664b69aecd9a170f608 Mon Sep 17 00:00:00 2001 From: Joshua Judson Rosen Date: Sun, 23 Nov 2014 22:58:05 -0500 Subject: [PATCH 2/5] UserEmailSummaryHandler: correct instantiation of InboxNoticeStream It only takes a single Profile argument.... --- plugins/EmailSummary/lib/useremailsummaryhandler.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/EmailSummary/lib/useremailsummaryhandler.php b/plugins/EmailSummary/lib/useremailsummaryhandler.php index fe814a3fb5..8dbcefc11e 100644 --- a/plugins/EmailSummary/lib/useremailsummaryhandler.php +++ b/plugins/EmailSummary/lib/useremailsummaryhandler.php @@ -103,7 +103,7 @@ class UserEmailSummaryHandler extends QueueHandler } // An InboxNoticeStream for a certain user, scoped to its own view - $stream = new InboxNoticeStream($profile, $profile); + $stream = new InboxNoticeStream($profile); $notice = $stream->getNotices(0, self::MAX_NOTICES, $since_id); From bf0f22744da62498e648de992df6528d9973da8b Mon Sep 17 00:00:00 2001 From: Joshua Judson Rosen Date: Sun, 23 Nov 2014 23:03:14 -0500 Subject: [PATCH 3/5] UserEmailSummaryHandler: Update notice-fetching logic InboxNoticeStream::getNotices() no longer returns an ArrayWrapper; just fetch notices normally via $notice->fetch(), so that we can actually get the top notice-ID and update email_summary_status accordingly--and not mail about the same notices repeatedly. --- plugins/EmailSummary/lib/useremailsummaryhandler.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/EmailSummary/lib/useremailsummaryhandler.php b/plugins/EmailSummary/lib/useremailsummaryhandler.php index 8dbcefc11e..ec86e59d19 100644 --- a/plugins/EmailSummary/lib/useremailsummaryhandler.php +++ b/plugins/EmailSummary/lib/useremailsummaryhandler.php @@ -117,8 +117,8 @@ class UserEmailSummaryHandler extends QueueHandler $new_top = null; - if ($notice instanceof ArrayWrapper) { - $new_top = $notice->_items[0]->id; + if ($notice->fetch()) { + $new_top = $notice->id; } // TRANS: Subject for e-mail. @@ -145,7 +145,7 @@ class UserEmailSummaryHandler extends QueueHandler $out->elementStart('table', array('width' => '550px', 'style' => 'border: none; border-collapse: collapse;', 'cellpadding' => '6')); - while ($notice->fetch()) { + do { $profile = Profile::getKV('id', $notice->profile_id); if (empty($profile)) { @@ -189,7 +189,7 @@ class UserEmailSummaryHandler extends QueueHandler $out->elementEnd('div'); $out->elementEnd('td'); $out->elementEnd('tr'); - } + } while ($notice->fetch()); $out->elementEnd('table'); From 2d7804b88ffcdcc8378f684da08f2936aa8347e6 Mon Sep 17 00:00:00 2001 From: Joshua Judson Rosen Date: Sun, 23 Nov 2014 23:05:13 -0500 Subject: [PATCH 4/5] UserEmailSummaryHandler: use $notice->getLocalUrl(), not getUrl() getUrl() doesn't work on all notices anymore. --- plugins/EmailSummary/lib/useremailsummaryhandler.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/EmailSummary/lib/useremailsummaryhandler.php b/plugins/EmailSummary/lib/useremailsummaryhandler.php index ec86e59d19..f900d93595 100644 --- a/plugins/EmailSummary/lib/useremailsummaryhandler.php +++ b/plugins/EmailSummary/lib/useremailsummaryhandler.php @@ -173,7 +173,7 @@ class UserEmailSummaryHandler extends QueueHandler $out->text(' '); $out->raw($notice->rendered); $out->elementStart('div', array('style' => 'font-size: 0.8em; padding-top: 4px;')); - $noticeurl = $notice->getUrl(); + $noticeurl = $notice->getLocalUrl(); // above should always return an URL assert(!empty($noticeurl)); $out->elementStart('a', array('rel' => 'bookmark', From cff8c462da9d17cd06a2eaa282efb041e5c420f1 Mon Sep 17 00:00:00 2001 From: Joshua Judson Rosen Date: Mon, 24 Nov 2014 20:28:31 -0500 Subject: [PATCH 5/5] sendemailsummary.php: correct path to INSTALLDIR So that we can actually find commandline.inc. This should have been updated when the files in the EmailSummary tree where moved down a level into subdirectories. --- plugins/EmailSummary/scripts/sendemailsummary.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/EmailSummary/scripts/sendemailsummary.php b/plugins/EmailSummary/scripts/sendemailsummary.php index 01c11a210a..06a5327f61 100644 --- a/plugins/EmailSummary/scripts/sendemailsummary.php +++ b/plugins/EmailSummary/scripts/sendemailsummary.php @@ -17,7 +17,7 @@ * along with this program. If not, see . */ -define('INSTALLDIR', realpath(dirname(__FILE__) . '/../..')); +define('INSTALLDIR', realpath(dirname(__FILE__) . '/../../..')); $shortoptions = 'i:n:au'; $longoptions = array('id=', 'nickname=', 'all', 'universe');