From: Joshua Rüsweg Date: Thu, 9 Jan 2020 22:12:36 +0000 (+0100) Subject: Prevent duplicates in special trophy assignment X-Git-Tag: 5.2.2~65 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=e74ac39f0e43a19f39e22cdcdca6a0d30245dc33;p=GitHub%2FWoltLab%2FWCF.git Prevent duplicates in special trophy assignment If a trophy is taken away and added again shortly afterwards, the error may occur that the trophy can be marked twice as "Special". In this case, this leads to an error. We prevent this by making the whole thing clear. --- diff --git a/wcfsetup/install/files/lib/data/user/trophy/UserTrophyAction.class.php b/wcfsetup/install/files/lib/data/user/trophy/UserTrophyAction.class.php index eff4a7a9ad..dea4a5502b 100644 --- a/wcfsetup/install/files/lib/data/user/trophy/UserTrophyAction.class.php +++ b/wcfsetup/install/files/lib/data/user/trophy/UserTrophyAction.class.php @@ -69,9 +69,9 @@ class UserTrophyAction extends AbstractDatabaseObjectAction { if (!$hasTrophy) { $userProfileAction = new UserProfileAction([$userTrophy->getUserProfile()->getDecoratedObject()], 'updateSpecialTrophies', [ - 'trophyIDs' => array_merge(array_map(function($trophy) { + 'trophyIDs' => array_unique(array_merge(array_map(function($trophy) { return $trophy->trophyID; - }, $userTrophy->getUserProfile()->getSpecialTrophies()), [$userTrophy->trophyID]) + }, $userTrophy->getUserProfile()->getSpecialTrophies()), [$userTrophy->trophyID])) ]); $userProfileAction->executeAction(); }