From b7f92ec7c0310fef69f38f574745617f1fdb34e3 Mon Sep 17 00:00:00 2001 From: joshuaruesweg Date: Wed, 1 Jul 2020 21:51:20 +0200 Subject: [PATCH] Simplify checking of existing of conditions on revoking trophies See #3422 --- .../trophy/condition/TrophyConditionHandler.class.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/wcfsetup/install/files/lib/system/trophy/condition/TrophyConditionHandler.class.php b/wcfsetup/install/files/lib/system/trophy/condition/TrophyConditionHandler.class.php index c366962c74..4c4c33561c 100644 --- a/wcfsetup/install/files/lib/system/trophy/condition/TrophyConditionHandler.class.php +++ b/wcfsetup/install/files/lib/system/trophy/condition/TrophyConditionHandler.class.php @@ -149,19 +149,20 @@ class TrophyConditionHandler extends SingletonFactory { // extract the condition builder from the object. $pseudoUserList = new UserList(); - // Assign the condition to the pseudo DBOList object $conditions = $trophy->getConditions(); - foreach ($conditions as $condition) { - $condition->getObjectType()->getProcessor()->addUserCondition($condition, $pseudoUserList); - } // Check if there are conditions for the award of the trophy for the given trophy. // If there are no conditions, we simply return an empty list and do not remove any trophy. // A trophy without conditions that is awarded automatically cannot be created by default. - if (empty($pseudoUserList->getConditionBuilder()->__toString())) { + if (empty($conditions)) { return []; } + // Assign the condition to the pseudo DBOList object + foreach ($conditions as $condition) { + $condition->getObjectType()->getProcessor()->addUserCondition($condition, $pseudoUserList); + } + // Now we create our own query to find out which users no longer meet the conditions. // For this we use a UserList object again and transfer basic data from the pseudo object. $userList = new UserList(); -- 2.20.1