From dc70504d586837966b1a05889cc9307f1abf491a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Joshua=20R=C3=BCsweg?= Date: Thu, 3 May 2018 15:21:23 +0200 Subject: [PATCH] Load reactions with initialization of the object See #2508 --- .../lib/data/like/object/LikeObject.class.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/wcfsetup/install/files/lib/data/like/object/LikeObject.class.php b/wcfsetup/install/files/lib/data/like/object/LikeObject.class.php index f1067e0996..1eef13a34d 100644 --- a/wcfsetup/install/files/lib/data/like/object/LikeObject.class.php +++ b/wcfsetup/install/files/lib/data/like/object/LikeObject.class.php @@ -2,9 +2,11 @@ declare(strict_types=1); namespace wcf\data\like\object; use wcf\data\object\type\ObjectTypeCache; +use wcf\data\reaction\type\ReactionTypeCache; use wcf\data\user\User; use wcf\data\DatabaseObject; use wcf\system\WCF; +use wcf\util\JSON; /** * Represents a liked object. @@ -71,7 +73,20 @@ class LikeObject extends DatabaseObject { $cachedReactions = @unserialize($data['cachedReactions']); if (is_array($cachedReactions)) { - $this->reactions = $cachedReactions; + foreach ($cachedReactions as $reactionTypeID => $reactionCount) { + $reaction = ReactionTypeCache::getInstance()->getReactionTypeByID($reactionTypeID); + + // prevent outdated reactions + if ($reaction !== null) { + $this->reactions[$reactionTypeID] = [ + 'reactionCount' => $reactionCount, + 'renderedReactionIcon' => $reaction->renderIcon(), + 'renderedReactionIconEncoded' => JSON::encode($reaction->renderIcon()), + 'reactionTitle' => $reaction->getTitle(), + 'reactionType' => $reaction->type + ]; + } + } } } } -- 2.20.1