diff options
| author | Jan-Hendrik Willms <tleilax+studip@gmail.com> | 2022-06-23 08:05:40 +0000 |
|---|---|---|
| committer | Jan-Hendrik Willms <tleilax+studip@gmail.com> | 2022-06-23 08:05:40 +0000 |
| commit | df3965cd952d04e2a08b4be6426f6fbe1832e802 (patch) | |
| tree | bc19611baf8ce6e6ae65f3a68bb837c931f63097 /lib/plugins | |
| parent | 7ae6beeff40b256829a72166943cc823a8e03421 (diff) | |
fix role loading for nobody, fixes #1209
Closes #1209
Merge request studip/studip!718
Diffstat (limited to 'lib/plugins')
| -rw-r--r-- | lib/plugins/db/RolePersistence.class.php | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/lib/plugins/db/RolePersistence.class.php b/lib/plugins/db/RolePersistence.class.php index 60b0b65..d24c2a6 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); |
