X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/07de6ecdc5c69a34618ea954183e5630baeb0456..refs/pull/5280/head:/app/Activity/Tools/CommentTree.php diff --git a/app/Activity/Tools/CommentTree.php b/app/Activity/Tools/CommentTree.php index 559edccf3..16f6804ea 100644 --- a/app/Activity/Tools/CommentTree.php +++ b/app/Activity/Tools/CommentTree.php @@ -41,6 +41,17 @@ class CommentTree return $this->tree; } + public function canUpdateAny(): bool + { + foreach ($this->comments as $comment) { + if (userCan('comment-update', $comment)) { + return true; + } + } + + return false; + } + /** * @param Comment[] $comments */ @@ -65,7 +76,7 @@ class CommentTree } $tree = []; - foreach ($childMap[0] as $childId) { + foreach ($childMap[0] ?? [] as $childId) { $tree[] = $this->createTreeForId($childId, 0, $byId, $childMap); }