From ce4a217c21f1392adfe9a18fe13a15f4026a750f Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Tue, 20 Apr 2021 16:00:42 +0200 Subject: [PATCH] Consider user list box conditions when using cache builder internally --- .../lib/system/box/UserListBoxController.class.php | 11 +++++++++-- .../builder/AbstractSortedUserCacheBuilder.class.php | 10 ++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/wcfsetup/install/files/lib/system/box/UserListBoxController.class.php b/wcfsetup/install/files/lib/system/box/UserListBoxController.class.php index 56797fa4d2..7af672c311 100644 --- a/wcfsetup/install/files/lib/system/box/UserListBoxController.class.php +++ b/wcfsetup/install/files/lib/system/box/UserListBoxController.class.php @@ -1,11 +1,13 @@ sortOrder && $this->sortField && isset($this->cacheBuilders[$this->sortField])) { + $conditions = array_filter($this->box->getConditions(), function(Condition $condition) { + return $condition->getObjectType()->getProcessor() instanceof IObjectListCondition; + }); + $this->userIDs = call_user_func([$this->cacheBuilders[$this->sortField], 'getInstance'])->getData([ - 'limit' => $this->limit, - 'sortOrder' => $this->sortOrder + 'conditions' => $conditions, + 'limit' => $this->limit, + 'sortOrder' => $this->sortOrder, ]); } diff --git a/wcfsetup/install/files/lib/system/cache/builder/AbstractSortedUserCacheBuilder.class.php b/wcfsetup/install/files/lib/system/cache/builder/AbstractSortedUserCacheBuilder.class.php index 281c454818..fee3852aec 100644 --- a/wcfsetup/install/files/lib/system/cache/builder/AbstractSortedUserCacheBuilder.class.php +++ b/wcfsetup/install/files/lib/system/cache/builder/AbstractSortedUserCacheBuilder.class.php @@ -1,6 +1,8 @@ positiveValuesOnly) { $userProfileList->getConditionBuilder()->add('user_table.'.$this->sortField.' > ?', [0]); } + if (isset($parameters['conditions'])) { + /** @var Condition $condition */ + foreach ($parameters['conditions'] as $condition) { + /** @var IObjectListCondition $processor */ + $processor = $condition->getObjectType()->getProcessor(); + $processor->addObjectListCondition($userProfileList, $condition->conditionData); + } + } $userProfileList->sqlOrderBy = 'user_table.'.$this->sortField.' '.$sortOrder; $userProfileList->sqlLimit = !empty($parameters['limit']) ? $parameters['limit'] : $this->defaultLimit; $userProfileList->readObjectIDs(); -- 2.20.1