From 99a41d35a304bf802e10a6f285f2f1f424f9d920 Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Sat, 5 Aug 2017 09:28:40 +0200 Subject: [PATCH] Update comments counters after comment creation for test notifications See #2359 --- ...ableCommentResponseUserNotificationEvent.class.php | 6 ++++++ .../TTestableCommentUserNotificationEvent.class.php | 11 ++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/wcfsetup/install/files/lib/system/user/notification/event/TTestableCommentResponseUserNotificationEvent.class.php b/wcfsetup/install/files/lib/system/user/notification/event/TTestableCommentResponseUserNotificationEvent.class.php index 07826f7463..37cb05237f 100644 --- a/wcfsetup/install/files/lib/system/user/notification/event/TTestableCommentResponseUserNotificationEvent.class.php +++ b/wcfsetup/install/files/lib/system/user/notification/event/TTestableCommentResponseUserNotificationEvent.class.php @@ -5,7 +5,9 @@ use wcf\data\comment\response\CommentResponseAction; use wcf\data\comment\Comment; use wcf\data\comment\CommentAction; use wcf\data\comment\CommentEditor; +use wcf\data\object\type\ObjectTypeCache; use wcf\data\user\UserProfile; +use wcf\system\comment\manager\ICommentManager; use wcf\system\user\notification\object\CommentResponseUserNotificationObject; use wcf\system\user\notification\object\IUserNotificationObject; @@ -53,6 +55,10 @@ trait TTestableCommentResponseUserNotificationEvent { ], self::getTestCommentObjectData($recipient, $author)) ]))->executeAction()['returnValues']; + /** @var ICommentManager $commentManager */ + $commentManager = ObjectTypeCache::getInstance()->getObjectType($comment->objectTypeID)->getProcessor(); + $commentManager->updateCounter($comment->objectID, 1); + /** @var CommentResponse $commentResponse */ $commentResponse = (new CommentResponseAction([], 'create', [ 'data' => [ diff --git a/wcfsetup/install/files/lib/system/user/notification/event/TTestableCommentUserNotificationEvent.class.php b/wcfsetup/install/files/lib/system/user/notification/event/TTestableCommentUserNotificationEvent.class.php index f8b44f38ff..a3701a0649 100644 --- a/wcfsetup/install/files/lib/system/user/notification/event/TTestableCommentUserNotificationEvent.class.php +++ b/wcfsetup/install/files/lib/system/user/notification/event/TTestableCommentUserNotificationEvent.class.php @@ -2,7 +2,9 @@ namespace wcf\system\user\notification\event; use wcf\data\comment\Comment; use wcf\data\comment\CommentAction; +use wcf\data\object\type\ObjectTypeCache; use wcf\data\user\UserProfile; +use wcf\system\comment\manager\ICommentManager; use wcf\system\user\notification\object\CommentUserNotificationObject; use wcf\system\user\notification\object\IUserNotificationObject; @@ -38,7 +40,8 @@ trait TTestableCommentUserNotificationEvent { * @return Comment */ public static function createTestComment(UserProfile $recipient, UserProfile $author) { - return (new CommentAction([], 'create', [ + /** @var Comment $comment */ + $comment = (new CommentAction([], 'create', [ 'data' => array_merge([ 'enableHtml' => 1, 'isDisabled' => 0, @@ -48,6 +51,12 @@ trait TTestableCommentUserNotificationEvent { 'username' => $recipient->username ], self::getTestCommentObjectData($recipient, $author)) ]))->executeAction()['returnValues']; + + /** @var ICommentManager $commentManager */ + $commentManager = ObjectTypeCache::getInstance()->getObjectType($comment->objectTypeID)->getProcessor(); + $commentManager->updateCounter($comment->objectID, 1); + + return $comment; } /** -- 2.20.1