From: Joshua Rüsweg Date: Fri, 5 Jul 2019 11:55:26 +0000 (+0200) Subject: Fix calculating of neutral reactions for objects after revert a reaction X-Git-Tag: 5.2.0_Alpha_2~41^2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=df39042789a5a428b934c952dd61bc3c2e2ed371;p=GitHub%2FWoltLab%2FWCF.git Fix calculating of neutral reactions for objects after revert a reaction --- 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) ];