Exception handling for notice parent fetching

This commit is contained in:
Mikael Nordfeldth 2015-06-02 14:04:22 +02:00
parent c4683bb3ba
commit d69453f846

View File

@ -698,13 +698,17 @@ class QvitterPlugin extends Plugin {
$reply_notification_to = false; $reply_notification_to = false;
// check for reply to insert in notifications // check for reply to insert in notifications
if($notice->reply_to) { if($notice->reply_to) {
$replyparent = $notice->getParent(); try {
$replyauthor = $replyparent->getProfile(); $replyauthor = $notice->getParent()->getProfile();
if ($replyauthor instanceof Profile) {
$reply_notification_to = $replyauthor->id; $reply_notification_to = $replyauthor->id;
$this->insertNotification($replyauthor->id, $notice->profile_id, 'reply', $notice->id); $this->insertNotification($replyauthor->id, $notice->profile_id, 'reply', $notice->id);
} //} catch (NoParentNoticeException $e) { // TODO: catch this when everyone runs latest GNU social!
// This is not a reply to something (has no parent)
} catch (NoResultException $e) {
// Parent notice or its author's profile not found! Complain louder?
common_log(LOG_ERR, 'NoResultException: '.$e->getMessage());
} }
}
// check for mentions to insert in notifications // check for mentions to insert in notifications
$mentions = common_find_mentions($notice->content, $notice); $mentions = common_find_mentions($notice->content, $notice);