From: Tim Düsterhus Date: Sun, 17 Jul 2016 19:03:35 +0000 (+0200) Subject: Remove magic number in ModerationQueueAction::getOutstandingQueues() X-Git-Tag: 3.0.0_Beta_1~1058 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=9b78beb9ec5b0f039933924a607c0fd4a68404f0;p=GitHub%2FWoltLab%2FWCF.git Remove magic number in ModerationQueueAction::getOutstandingQueues() --- diff --git a/wcfsetup/install/files/lib/data/moderation/queue/ModerationQueueAction.class.php b/wcfsetup/install/files/lib/data/moderation/queue/ModerationQueueAction.class.php index 001c83ede5..90c9fcc5c4 100644 --- a/wcfsetup/install/files/lib/data/moderation/queue/ModerationQueueAction.class.php +++ b/wcfsetup/install/files/lib/data/moderation/queue/ModerationQueueAction.class.php @@ -103,6 +103,9 @@ class ModerationQueueAction extends AbstractDatabaseObjectAction { * @return string[] */ public function getOutstandingQueues() { + // Maximum cardinality of the returned array + static $MAX_ITEMS = 10; + $conditions = new PreparedStatementConditionBuilder(); $conditions->add("moderation_queue_to_user.userID = ?", [WCF::getUser()->userID]); $conditions->add("moderation_queue_to_user.isAffected = ?", [1]); @@ -118,7 +121,7 @@ class ModerationQueueAction extends AbstractDatabaseObjectAction { ON (tracked_visit.objectTypeID = ".VisitTracker::getInstance()->getObjectTypeID('com.woltlab.wcf.moderation.queue')." AND tracked_visit.objectID = moderation_queue.queueID AND tracked_visit.userID = ".WCF::getUser()->userID.") ".$conditions." ORDER BY moderation_queue.lastChangeTime DESC"; - $statement = WCF::getDB()->prepareStatement($sql, 10); + $statement = WCF::getDB()->prepareStatement($sql, $MAX_ITEMS); $statement->execute($conditions->getParameters()); $queueIDs = $statement->fetchAll(\PDO::FETCH_COLUMN); @@ -137,13 +140,13 @@ class ModerationQueueAction extends AbstractDatabaseObjectAction { // check if user storage is outdated $totalCount = ModerationQueueManager::getInstance()->getUnreadModerationCount(); $count = count($queues); - if ($count < 10) { + if ($count < $MAX_ITEMS) { // load more entries to fill up list $queueList = new ViewableModerationQueueList(); $queueList->getConditionBuilder()->add("moderation_queue.status IN (?)", [[ModerationQueue::STATUS_OUTSTANDING, ModerationQueue::STATUS_PROCESSING]]); if (!empty($queueIDs)) $queueList->getConditionBuilder()->add("moderation_queue.queueID NOT IN (?)", [$queueIDs]); $queueList->sqlOrderBy = "moderation_queue.lastChangeTime DESC"; - $queueList->sqlLimit = 10 - $count; + $queueList->sqlLimit = $MAX_ITEMS - $count; $queueList->loadUserProfiles = true; $queueList->readObjects(); foreach ($queueList as $queue) {