From 3a6c98ff164e5c77c5ced29750e2259c815ef0b4 Mon Sep 17 00:00:00 2001 From: Mikael Nordfeldth Date: Wed, 30 Sep 2015 22:55:06 +0200 Subject: [PATCH] NoResultException is common if reply_to was not cleared on parent deletion --- classes/Notice.php | 4 ++++ lib/apiaction.php | 3 +++ lib/implugin.php | 7 +++++-- lib/util.php | 2 ++ plugins/Xmpp/XmppPlugin.php | 3 +++ 5 files changed, 17 insertions(+), 2 deletions(-) diff --git a/classes/Notice.php b/classes/Notice.php index e4d10a5bad..44d5adb1b7 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -1630,6 +1630,8 @@ class Notice extends Managed_DataObject self::blow('reply:stream:%d', $parentauthor->id); } catch (NoParentNoticeException $e) { // Not a reply, since it has no parent! + } catch (NoResultException $e) { + // Parent notice was probably deleted } // @todo ideally this parser information would only @@ -1855,6 +1857,8 @@ class Notice extends Managed_DataObject $ctx->replyToUrl = $reply->getUrl(true); // true for fallback to local URL, less messy } catch (NoParentNoticeException $e) { // This is not a reply to something + } catch (NoResultException $e) { + // Parent notice was probably deleted } try { diff --git a/lib/apiaction.php b/lib/apiaction.php index 3564709e5b..1bd80ad122 100644 --- a/lib/apiaction.php +++ b/lib/apiaction.php @@ -330,6 +330,9 @@ class ApiAction extends Action $in_reply_to = $parent->id; } catch (NoParentNoticeException $e) { $in_reply_to = null; + } catch (NoResultException $e) { + // the in_reply_to message has probably been deleted + $in_reply_to = null; } $twitter_status['in_reply_to_status_id'] = $in_reply_to; diff --git a/lib/implugin.php b/lib/implugin.php index 742147dbbd..457c9dba52 100644 --- a/lib/implugin.php +++ b/lib/implugin.php @@ -364,13 +364,16 @@ abstract class ImPlugin extends Plugin protected function formatNotice(Notice $notice) { $profile = $notice->getProfile(); + $nicknames = $profile->getNickname(); try { $parent = $notice->getParent(); $orig_profile = $parent->getProfile(); - $nicknames = sprintf('%1$s => %2$s', $profile->nickname, $orig_profile->nickname); + $nicknames = sprintf('%1$s => %2$s', $profile->getNickname(), $orig_profile->getNickname()); } catch (NoParentNoticeException $e) { - $nicknames = $profile->nickname; + // Not a reply, no parent notice stored + } catch (NoResultException $e) { + // Parent notice was probably deleted } return sprintf('%1$s: %2$s [%3$u]', $nicknames, $notice->content, $notice->id); diff --git a/lib/util.php b/lib/util.php index 9c37a5e669..a5acd8d86b 100644 --- a/lib/util.php +++ b/lib/util.php @@ -725,6 +725,8 @@ function common_find_mentions($text, Notice $notice) } } catch (NoParentNoticeException $e) { // It wasn't a reply to anything, so we can't harvest nickname-relations. + } catch (NoResultException $e) { + // The parent notice was deleted. } $matches = common_find_mentions_raw($text); diff --git a/plugins/Xmpp/XmppPlugin.php b/plugins/Xmpp/XmppPlugin.php index 04101a8e2b..8c700bae8b 100644 --- a/plugins/Xmpp/XmppPlugin.php +++ b/plugins/Xmpp/XmppPlugin.php @@ -351,6 +351,9 @@ class XmppPlugin extends ImPlugin $xs->text(sprintf(' => %s', $orig_profile->nickname)); } catch (NoParentNoticeException $e) { $xs->text(": "); + } catch (NoResultException $e) { + // Parent notice was probably deleted. + $xs->text(": "); } if (!empty($notice->rendered)) { $notice->rendered = str_replace("\t", "", $notice->rendered); -- 2.39.5