From 05c8cbc1e1c43578b596f2ce86f145f057480637 Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 4 Jan 2018 20:59:19 +0000 Subject: [PATCH] Precaution for incomplete threads --- include/conversation.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/include/conversation.php b/include/conversation.php index 0a565c68e3..5edcb09da2 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -929,6 +929,20 @@ function community_add_items($parents) { ); $comments = dba::inArray($thread_items); + // Check if the original item is in the result. + // When commenting from the community page there can be incomplete threads + if (count($comments) > 0) { + $parent_found = false; + foreach ($comments as $comment) { + if ($comment['uri'] == $comment['parent-uri']) { + $parent_found = true; + break; + } + } + if (!$parent_found) { + $comments = array(); + } + } if (count($comments) == 0) { $thread_items = dba::p(item_query()." AND `item`.`uid` = 0