From 56173b0297eb0e599425fca41dfdade12dce1487 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 4 Dec 2024 09:18:46 +0100 Subject: [PATCH] Fix avoid duplicate filter IN (0, 0) --- htdocs/user/class/user.class.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 975cbefb98a..9c2f051e51c 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -597,7 +597,11 @@ class User extends CommonObject if (isModEnabled('multicompany') && getDolGlobalString('MULTICOMPANY_TRANSVERSE_MODE')) { $sql .= " WHERE u.entity IS NOT NULL"; // multicompany is on in transverse mode or user making fetch is on entity 0, so user is allowed to fetch anywhere into database } else { - $sql .= " WHERE u.entity IN (0, ".((int) (($entity != '' && $entity >= 0) ? $entity : $conf->entity)).")"; // search in entity provided in parameter + if ($entity != '' && $entity == 0) { // If $entity = 0 + $sql .= " WHERE u.entity = 0"; + } else { // if $entity is -1 or > 0 + $sql .= " WHERE u.entity IN (0, ".((int) ($entity > 0 ? $entity : $conf->entity)).")"; + } } }