Fixed update of comment counters
authorAlexander Ebert <ebert@woltlab.com>
Tue, 7 Nov 2017 11:24:41 +0000 (12:24 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Tue, 7 Nov 2017 11:24:48 +0000 (12:24 +0100)
wcfsetup/install/files/lib/data/comment/CommentAction.class.php
wcfsetup/install/files/lib/data/comment/response/CommentResponseAction.class.php

index d2da056a73556556c5e2bd77e8b25c8ea0a8e280..1929ccbe257eec5063f268f849c4a67ac9275556 100644 (file)
@@ -109,6 +109,7 @@ class CommentAction extends AbstractDatabaseObjectAction implements IMessageInli
                }
                
                // update counters
+               /** @var ICommentManager[] $processors */
                $processors = [];
                $groupCommentIDs = $commentIDs = [];
                foreach ($this->getObjects() as $comment) {
@@ -119,7 +120,10 @@ class CommentAction extends AbstractDatabaseObjectAction implements IMessageInli
                                $groupCommentIDs[$comment->objectTypeID] = [];
                        }
                        
-                       $processors[$comment->objectTypeID]->updateCounter($comment->objectID, -1 * ($comment->responses + 1));
+                       if (!$comment->isDisabled) {
+                               $processors[$comment->objectTypeID]->updateCounter($comment->objectID, -1 * ($comment->responses + 1));
+                       }
+                       
                        $groupCommentIDs[$comment->objectTypeID][] = $comment->commentID;
                        $commentIDs[] = $comment->commentID;
                }
index 57ec07304b35de2439bdfcb03974e193aa9e54c8..9dff1affb9997bfc9d29695d5e9044266f6c051c 100644 (file)
@@ -96,6 +96,7 @@ class CommentResponseAction extends AbstractDatabaseObjectAction {
                $comments = $commentList->getObjects();
                
                // update counters
+               /** @var ICommentManager[] $processors */
                $processors = $responseIDs = $updateComments = [];
                foreach ($this->getObjects() as $response) {
                        $objectTypeID = $comments[$response->commentID]->objectTypeID;
@@ -107,7 +108,7 @@ class CommentResponseAction extends AbstractDatabaseObjectAction {
                        }
                        $responseIDs[$objectTypeID][] = $response->responseID;
                        
-                       if (!$ignoreCounters) {
+                       if (!$ignoreCounters && !$response->isDisabled) {
                                $processors[$objectTypeID]->updateCounter($comments[$response->commentID]->objectID, -1);
                                
                                if (!isset($updateComments[$response->commentID])) {
@@ -126,9 +127,11 @@ class CommentResponseAction extends AbstractDatabaseObjectAction {
                        foreach ($comments as $comment) {
                                $commentEditor = new CommentEditor($comment);
                                $commentEditor->updateResponseIDs();
-                               $commentEditor->updateCounters([
-                                       'responses' => -1 * $updateComments[$comment->commentID]
-                               ]);
+                               if (isset($updateComments[$comment->commentID])) {
+                                       $commentEditor->updateCounters([
+                                               'responses' => -1 * $updateComments[$comment->commentID]
+                                       ]);
+                               }
                        }
                }