From e74ac39f0e43a19f39e22cdcdca6a0d30245dc33 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Joshua=20R=C3=BCsweg?= Date: Thu, 9 Jan 2020 23:12:36 +0100 Subject: [PATCH] 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. --- .../files/lib/data/user/trophy/UserTrophyAction.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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(); } -- 2.20.1