prevent corrupt notifications without notice_id

This commit is contained in:
Hannes Mannerheim 2015-01-20 15:14:46 +01:00
parent 15daae0a36
commit bbbbfb2920
2 changed files with 3 additions and 2 deletions

View File

@ -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);
}
}

View File

@ -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()) {