From: Joshua Rüsweg Date: Thu, 2 Aug 2018 10:12:25 +0000 (+0200) Subject: Determine legacy reaction types for likes X-Git-Tag: 5.2.0_Alpha_1~364^2~101^2~32 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=d3fb71287ffb2116d1013b1b6ac810d2a943fc6e;p=GitHub%2FWoltLab%2FWCF.git Determine legacy reaction types for likes See #2508 --- diff --git a/wcfsetup/install/files/lib/system/reaction/ReactionHandler.class.php b/wcfsetup/install/files/lib/system/reaction/ReactionHandler.class.php index b62f1c666a..a21caa378c 100644 --- a/wcfsetup/install/files/lib/system/reaction/ReactionHandler.class.php +++ b/wcfsetup/install/files/lib/system/reaction/ReactionHandler.class.php @@ -751,14 +751,27 @@ class ReactionHandler extends SingletonFactory { * @return integer|null */ public function getLegacyReactionTypeID($type) { - // @TODO determine real values + $reactionTypes = ReactionTypeCache::getInstance()->getEnabledReactionTypes(); + ReactionType::sort($reactionTypes, 'showOrder'); switch ($type) { case ReactionType::REACTION_TYPE_POSITIVE: - return 2; + foreach ($reactionTypes as $reactionType) { + if ($reactionType->isPositive()) { + return $reactionType->reactionTypeID; + } + } + + return null; case ReactionType::REACTION_TYPE_NEGATIVE: - return 1; + foreach ($reactionTypes as $reactionType) { + if ($reactionType->isNegative()) { + return $reactionType->reactionTypeID; + } + } + return null; + default: throw new \LogicException('Invalid type given.'); }