From df3965cd952d04e2a08b4be6426f6fbe1832e802 Mon Sep 17 00:00:00 2001 From: Jan-Hendrik Willms <tleilax+studip@gmail.com> Date: Thu, 23 Jun 2022 08:05:40 +0000 Subject: [PATCH] fix role loading for nobody, fixes #1209 Closes #1209 Merge request studip/studip!718 --- lib/plugins/db/RolePersistence.class.php | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/lib/plugins/db/RolePersistence.class.php b/lib/plugins/db/RolePersistence.class.php index 60b0b6507f7..d24c2a6298f 100644 --- a/lib/plugins/db/RolePersistence.class.php +++ b/lib/plugins/db/RolePersistence.class.php @@ -221,21 +221,18 @@ class RolePersistence $cache = self::getUserRolesCache(); if (!isset($cache[$user_id])) { - $query = "SELECT DISTINCT * - FROM ( - SELECT `roleid`, `institut_id`, 1 AS explicit - FROM `roles_user` - WHERE `userid` = :user_id - - UNION - - SELECT `roleid`, '' AS institut_id, 0 AS explicit - FROM `roles_studipperms` - WHERE `permname` = :perm - ) AS tmp"; + $query = "SELECT `roleid`, `institut_id`, 1 AS explicit + FROM `roles_user` + WHERE `userid` = :user_id + + UNION ALL + + SELECT `roleid`, '' AS institut_id, 0 AS explicit + FROM `roles_studipperms` + WHERE `permname` = :perm"; $statement = DBManager::get()->prepare($query); $statement->bindValue(':user_id', $user_id); - $statement->bindValue(':perm', $GLOBALS['perm']->get_perm($user_id)); + $statement->bindValue(':perm', is_object($GLOBALS['perm']) ? $GLOBALS['perm']->get_perm($user_id) : 'nobody'); $statement->execute(); $statement->setFetchMode(PDO::FETCH_ASSOC); -- GitLab