From df39042789a5a428b934c952dd61bc3c2e2ed371 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Joshua=20R=C3=BCsweg?= Date: Fri, 5 Jul 2019 13:55:26 +0200 Subject: [PATCH] Fix calculating of neutral reactions for objects after revert a reaction --- .../files/lib/system/reaction/ReactionHandler.class.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/wcfsetup/install/files/lib/system/reaction/ReactionHandler.class.php b/wcfsetup/install/files/lib/system/reaction/ReactionHandler.class.php index f9a20fcb5b..986b38b09a 100644 --- a/wcfsetup/install/files/lib/system/reaction/ReactionHandler.class.php +++ b/wcfsetup/install/files/lib/system/reaction/ReactionHandler.class.php @@ -617,6 +617,7 @@ class ReactionHandler extends SingletonFactory { // update existing object $likes = $likeObject->likes; $dislikes = $likeObject->dislikes; + $neutralReactions = $likeObject->neutralReactions; $cumulativeLikes = $likeObject->cumulativeLikes; $cachedReactions = @unserialize($likeObject->cachedReactions); if (!is_array($cachedReactions)) { @@ -632,6 +633,12 @@ class ReactionHandler extends SingletonFactory { $dislikes--; $cumulativeLikes++; } + else if ($like->getReactionType()->isNeutral()) { + $neutralReactions--; + } + else { + throw new \LogicException('Unreachable'); + } if (isset($cachedReactions[$like->getReactionType()->reactionTypeID])) { if (--$cachedReactions[$like->getReactionType()->reactionTypeID] == 0) { @@ -643,6 +650,7 @@ class ReactionHandler extends SingletonFactory { $updateData = [ 'likes' => $likes, 'dislikes' => $dislikes, + 'neutralReactions' => $neutralReactions, 'cumulativeLikes' => $cumulativeLikes, 'cachedReactions' => serialize($cachedReactions) ]; -- 2.20.1