From c85b88c1b62e8fe9f651576eae9b2e025775eaf5 Mon Sep 17 00:00:00 2001 From: Simey Lameze Date: Tue, 14 Jun 2022 11:47:30 +0800 Subject: [PATCH] MDL-74967 core: deprecate groupmember hack from USER object --- lib/modinfolib.php | 5 ----- lib/moodlelib.php | 17 ----------------- lib/upgrade.txt | 2 ++ 3 files changed, 2 insertions(+), 22 deletions(-) diff --git a/lib/modinfolib.php b/lib/modinfolib.php index f84c0fcbfac..ae07d8a13e7 100644 --- a/lib/modinfolib.php +++ b/lib/modinfolib.php @@ -287,11 +287,6 @@ class course_modinfo { */ private function get_groups_all() { if (is_null($this->groups)) { - // NOTE: Performance could be improved here. The system caches user groups - // in $USER->groupmember[$courseid] => array of groupid=>groupid. Unfortunately this - // structure does not include grouping information. It probably could be changed to - // do so, without a significant performance hit on login, thus saving this one query - // each request. $this->groups = groups_get_user_groups($this->course->id, $this->userid); } return $this->groups; diff --git a/lib/moodlelib.php b/lib/moodlelib.php index 1adab8de923..a3f522a8a5e 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -4883,23 +4883,6 @@ function get_complete_user_data($field, $value, $mnethostid = null, $throwexcept } } - $sql = "SELECT g.id, g.courseid - FROM {groups} g, {groups_members} gm - WHERE gm.groupid=g.id AND gm.userid=?"; - - // This is a special hack to speedup calendar display. - $user->groupmember = array(); - if (!isguestuser($user)) { - if ($groups = $DB->get_records_sql($sql, array($user->id))) { - foreach ($groups as $group) { - if (!array_key_exists($group->courseid, $user->groupmember)) { - $user->groupmember[$group->courseid] = array(); - } - $user->groupmember[$group->courseid][$group->id] = $group->id; - } - } - } - // Add cohort theme. if (!empty($CFG->allowcohortthemes)) { require_once($CFG->dirroot . '/cohort/lib.php'); diff --git a/lib/upgrade.txt b/lib/upgrade.txt index 2c586fcf0db..59c819309c0 100644 --- a/lib/upgrade.txt +++ b/lib/upgrade.txt @@ -3,6 +3,8 @@ information provided here is intended especially for developers. === 4.1 === +* The $USER->groupmember hack that fills the user object with the groups that the user belongs to has been removed. + Please use the Groups API function groups_get_user_groups() to fetch the cached list of groups the user is a member of. * The method ensure_adhoc_task_qos() in lib/classes/task/manager.php has been deprecated, please use get_next_adhoc_task() instead. * New setting $CFG->enrolments_sync_interval controls the minimum time in seconds between re-synchronization of enrollment via enrol_check_plugins.