public function rebuildContentReactionCache($contentType, $contentId, $isLike = false, $throw = true)
{
...
$counts = $this->db()->fetchPairs("
SELECT reacted.reaction_id, COUNT(*) AS counts
FROM xf_reaction_content AS reacted
INNER JOIN xf_reaction AS reaction ON (reacted.reaction_id = reaction.reaction_id)
WHERE content_type = ? AND content_id = ? AND reaction.active = 1
GROUP BY reaction_id
ORDER BY counts DESC
", [$contentType, $contentId]);
if ($counts)
{
$latest = $this->db()->fetchAll("
SELECT user.user_id, user.username, reacted.reaction_id
FROM xf_reaction_content AS reacted
INNER JOIN xf_user AS user ON (reacted.reaction_user_id = user.user_id)
INNER JOIN xf_reaction AS reaction ON (reacted.reaction_id = reaction.reaction_id)
WHERE reacted.content_type = ? AND reacted.content_id = ? AND reaction.active = 1
ORDER BY reacted.reaction_date DESC
LIMIT 5
", [$contentType, $contentId]);
}
else
{
$latest = [];
}
}