From bbbbfb2920c678460a87d49d971caa4076ddb238 Mon Sep 17 00:00:00 2001 From: Hannes Mannerheim Date: Tue, 20 Jan 2015 15:14:46 +0100 Subject: [PATCH] prevent corrupt notifications without notice_id --- QvitterPlugin.php | 4 ++-- actions/apinewnotifications.php | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/QvitterPlugin.php b/QvitterPlugin.php index 4d07fac..aaa9500 100644 --- a/QvitterPlugin.php +++ b/QvitterPlugin.php @@ -631,7 +631,7 @@ class QvitterPlugin extends Plugin { if($notice->reply_to) { $replyparent = $notice->getParent(); $replyauthor = $replyparent->getProfile(); - if ($replyauthor instanceof Profile) { + if ($replyauthor instanceof Profile && !empty($notice->id)) { $reply_notification_to = $replyauthor->id; $this->insertNotification($replyauthor->id, $notice->profile_id, 'reply', $notice->id); } @@ -650,7 +650,7 @@ class QvitterPlugin extends Plugin { } // only notify if mentioned user is not already notified for reply - if($reply_notification_to != $mentioned->id) { + if($reply_notification_to != $mentioned->id && !empty($notice->id)) { $this->insertNotification($mentioned->id, $notice->profile_id, 'mention', $notice->id); } } diff --git a/actions/apinewnotifications.php b/actions/apinewnotifications.php index ffe0121..d0a57db 100644 --- a/actions/apinewnotifications.php +++ b/actions/apinewnotifications.php @@ -67,6 +67,7 @@ class ApiNewNotificationsAction extends ApiAction $notification->whereAdd("(to_profile_id = '".$user_id."')"); $notification->groupBy('ntype'); $notification->whereAdd("(is_seen = '0')"); + $notification->whereAdd("(notice_id != 'NULL')"); // sometimes notice_id is NULL, those notifications are corrupt and should be discarded $notification->find(); while ($notification->fetch()) {