Fixed fastUpdateReactionIsCounted/fastDeleteReactions do not correctly change user's reaction_score

Xon

Well-known member
Affected version
2.1.2
Both functions have this loop;
PHP:
foreach ($updates AS $userId => $contentId)
{
   $existingReaction = $this->getReactionByContentAndReactionUser($contentType, $contentId, $userId);
   $tally[$userId] = isset($tally[$userId]) ? $tally[$userId] + $existingReaction->reaction_score : 1;
}

getReactionByContentAndReactionUser returns an \XF\Entity\ReactionContent which does not contain a reaction_score field. The default 1 value, also means these functions do not properly handle reactions with zero or negative reaction scores.

Probably would be best for the function which fetches the updates to fetch the reaction_id and then skip the extra per-user query
 
On further study of these functions; fetchPair is the wrong query function is being used incorrectly. The user-id will be unique only multiple pieces of content, which is not what is wanted.
 
It looks like the changes for this bug report have fixed the referenced area here too:

 
Top Bottom