Consider user list box conditions when using cache builder internally
authorMatthias Schmidt <gravatronics@live.com>
Tue, 20 Apr 2021 14:00:42 +0000 (16:00 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Tue, 20 Apr 2021 14:00:42 +0000 (16:00 +0200)
wcfsetup/install/files/lib/system/box/UserListBoxController.class.php
wcfsetup/install/files/lib/system/cache/builder/AbstractSortedUserCacheBuilder.class.php

index 56797fa4d2643e77c2fdf46a0cebef3cf3ebeca2..7af672c311e09af4ba17723323093b16c75c8752 100644 (file)
@@ -1,11 +1,13 @@
 <?php
 namespace wcf\system\box;
+use wcf\data\condition\Condition;
 use wcf\data\user\UserProfileList;
 use wcf\data\DatabaseObject;
 use wcf\system\cache\builder\MostActiveMembersCacheBuilder;
 use wcf\system\cache\builder\MostLikedMembersCacheBuilder;
 use wcf\system\cache\builder\NewestMembersCacheBuilder;
 use wcf\system\cache\runtime\UserProfileRuntimeCache;
+use wcf\system\condition\IObjectListCondition;
 use wcf\system\event\EventHandler;
 use wcf\system\request\LinkHandler;
 use wcf\system\WCF;
@@ -93,9 +95,14 @@ class UserListBoxController extends AbstractDatabaseObjectListBoxController {
        protected function getObjectList() {
                // use specialized cache builders
                if ($this->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,
                        ]);
                }
                
index 281c454818b1ad36e48ca0bab189430f4f900520..fee3852aec066ea5a59f8b7dcce6a574e25b378e 100644 (file)
@@ -1,6 +1,8 @@
 <?php
 namespace wcf\system\cache\builder;
+use wcf\data\condition\Condition;
 use wcf\data\user\UserList;
+use wcf\system\condition\IObjectListCondition;
 
 /**
  * Caches a list of the newest members.
@@ -54,6 +56,14 @@ abstract class AbstractSortedUserCacheBuilder extends AbstractCacheBuilder {
                if ($this->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();