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.
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();
}