From b39421d32dad7ca67e530435092cb541212c86d8 Mon Sep 17 00:00:00 2001 From: Claus-Justus Heine Date: Fri, 18 Feb 2022 12:47:18 +0100 Subject: [PATCH] Selecting and counting users from the User-Group table needs DISTINCT to avoid duplicates. In particular when using the catch-all group ("Default Group" setting) the queries which count and select users from the User-Group table need the "DISTINCT" option: the catch-all group is replaced by a '%' wild-card in the query. As users may belong by design to more than one group counting and selecting users comes out wrong. Even worse: the many duplicates interfere with the paging logic of the user admin-settings. Signed-off-by: Claus-Justus Heine --- lib/Query/QueryProvider.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Query/QueryProvider.php b/lib/Query/QueryProvider.php index 7252cda..0a1f9c1 100644 --- a/lib/Query/QueryProvider.php +++ b/lib/Query/QueryProvider.php @@ -135,7 +135,7 @@ class QueryProvider implements \ArrayAccess "AND g.$gAdmin", Query::COUNT_GROUPS => - "SELECT COUNT(ug.$ugGID) " . + "SELECT COUNT(DISTINCT ug.$ugUID) " . "FROM $userGroup ug " . "WHERE ug.$ugGID LIKE :$gidParam " . "AND ug.$ugUID LIKE :$searchParam", @@ -152,7 +152,7 @@ class QueryProvider implements \ArrayAccess "WHERE g.$gGID = :$gidParam", Query::FIND_GROUP_USERS => - "SELECT ug.$ugUID AS uid " . + "SELECT DISTINCT ug.$ugUID AS uid " . "FROM $userGroup ug " . "WHERE ug.$ugGID LIKE :$gidParam " . "AND ug.$ugUID LIKE :$searchParam " .