From 82845626bca723c6d40fce5a5a7cf86ddbf7b3b9 Mon Sep 17 00:00:00 2001 From: Heath Dunlop Date: Thu, 16 May 2019 13:46:28 +1200 Subject: [PATCH] comments extension filters on Parent Class This allows both pages and DataObjects to have comments without the ParentID clashing and showing comments on a page where the ParentID is the Same as a DataObjects or even two DataObjects having the sameID --- src/Extensions/CommentsExtension.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Extensions/CommentsExtension.php b/src/Extensions/CommentsExtension.php index e1e5623..0a2132c 100644 --- a/src/Extensions/CommentsExtension.php +++ b/src/Extensions/CommentsExtension.php @@ -254,7 +254,10 @@ class CommentsExtension extends DataExtension { $order = $this->owner->getCommentsOption('order_comments_by'); $comments = Comment::get() - ->filter('ParentID', $this->owner->ID) + ->filter([ + 'ParentID' => $this->owner->ID, + 'ParentClass' => $this->owner->ClassName, + ]) ->sort($order); $this->owner->extend('updateAllComments', $comments); return $comments;