Update comments counters after comment creation for test notifications
authorMatthias Schmidt <gravatronics@live.com>
Sat, 5 Aug 2017 07:28:40 +0000 (09:28 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Sat, 5 Aug 2017 07:28:40 +0000 (09:28 +0200)
See #2359

wcfsetup/install/files/lib/system/user/notification/event/TTestableCommentResponseUserNotificationEvent.class.php
wcfsetup/install/files/lib/system/user/notification/event/TTestableCommentUserNotificationEvent.class.php

index 07826f746398007d815cf2bb88f55d11bad7a872..37cb05237f6dcc6caa06851968af5f01526f2be5 100644 (file)
@@ -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' => [
index f8b44f38ff48fdcc8b81d01410de0dbc8e6d1dff..a3701a06499712ff3f864c0f7a3c5c5aef29dad8 100644 (file)
@@ -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;
        }
        
        /**