]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/util.php
Non-replies cannot harvest parent notice nicknames
[quix0rs-gnu-social.git] / lib / util.php
index 4d696510892a0e0c17b266cb7b97beff537e3c1d..4949231c520545a7cb9295dfa982a696ec010fd5 100644 (file)
@@ -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);