From 019f57e1eabbe8270310c30f86980c8ce5d41483 Mon Sep 17 00:00:00 2001 From: Jan-Hendrik Willms <tleilax+studip@gmail.com> Date: Wed, 13 Nov 2024 15:11:51 +0000 Subject: [PATCH] fix pagination for users index jsonapi route, fixes #4844 Closes #4844 Merge request studip/studip!3630 --- lib/classes/JsonApi/Routes/Users/UsersIndex.php | 4 ++-- lib/classes/globalsearch/GlobalSearchUsers.php | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/classes/JsonApi/Routes/Users/UsersIndex.php b/lib/classes/JsonApi/Routes/Users/UsersIndex.php index c1a4fb7b8e4..e7f074a1115 100644 --- a/lib/classes/JsonApi/Routes/Users/UsersIndex.php +++ b/lib/classes/JsonApi/Routes/Users/UsersIndex.php @@ -35,8 +35,8 @@ class UsersIndex extends JsonApiController $this->validateFilters(); $filters = $this->getFilters(); - list($offset, $limit) = $this->getOffsetAndLimit(); - $partSQL = \GlobalSearchUsers::getSQL($filters['search'], [], $limit + $offset); + [$offset, $limit] = $this->getOffsetAndLimit(); + $partSQL = \GlobalSearchUsers::getSQL($filters['search'], [], "{$offset}, {$limit}"); $search_result = \DBManager::get()->fetchAll($partSQL); $total = (int) \DBManager::get()->fetchColumn('SELECT FOUND_ROWS() as found_rows'); diff --git a/lib/classes/globalsearch/GlobalSearchUsers.php b/lib/classes/globalsearch/GlobalSearchUsers.php index 458f0982101..24952ef1655 100644 --- a/lib/classes/globalsearch/GlobalSearchUsers.php +++ b/lib/classes/globalsearch/GlobalSearchUsers.php @@ -29,6 +29,11 @@ class GlobalSearchUsers extends GlobalSearchModule implements GlobalSearchFullte * @param string $search the input query string * @param array $filter an array with search limiting filter information (e.g. 'category', 'semester', etc.) * @return string SQL Query to discover elements for the search + * + * @todo If the signature of this method changes, the UsersIndex jsonapi + * route must also be taken into account. The route adds another + * parameter so that offset and limit can be used. + * @see \JsonApi\Routes\Users\UsersIndex::__invoke */ public static function getSQL($search, $filter, $limit) { -- GitLab