From 44dc00a58c4d0f3d78e7b6dc2cee13959e480aad Mon Sep 17 00:00:00 2001 From: Mikael Nordfeldth Date: Thu, 16 Jul 2015 12:53:10 +0200 Subject: [PATCH] Non-replies cannot harvest parent notice nicknames A feature we use of parent notices is that if you use the same @user as the parent notice, the same @user will be notified, regardless if there might be @user@site.com as well as @user@example.com and you're subscribed to just one of them (or both, or none of them!). But this threw an exception since we tested this on new notice threads. --- lib/util.php | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/lib/util.php b/lib/util.php index 4d69651089..4949231c52 100644 --- a/lib/util.php +++ b/lib/util.php @@ -710,18 +710,22 @@ function common_find_mentions($text, Notice $notice) // Is it a reply? - $origNotice = $notice->getParent(); - $origAuthor = $origNotice->getProfile(); + try { + $origNotice = $notice->getParent(); + $origAuthor = $origNotice->getProfile(); - $ids = $origNotice->getReplies(); + $ids = $origNotice->getReplies(); - foreach ($ids as $id) { - try { - $repliedTo = Profile::getByID($id); - $origMentions[$repliedTo->nickname] = $repliedTo; - } catch (NoResultException $e) { - // continue foreach + foreach ($ids as $id) { + try { + $repliedTo = Profile::getByID($id); + $origMentions[$repliedTo->getNickname()] = $repliedTo; + } catch (NoResultException $e) { + // continue foreach + } } + } catch (NoParentNoticeException $e) { + // It wasn't a reply to anything, so we can't harvest nickname-relations. } $matches = common_find_mentions_raw($text); -- 2.39.5