mirror of
https://github.com/moodle/moodle.git
synced 2025-08-06 09:26:35 +02:00
MDL-64049 core: Cache prefs for current user
We were already caching these preferences when a user object is provided to get_user_preferences, or when $USER is provided. This changee swaps get_user_preferences to use the global USER object when the USER->id matches the userid supplied to the function.
This commit is contained in:
parent
01acb1ea90
commit
8cba8d1a58
2 changed files with 10 additions and 13 deletions
|
@ -2088,7 +2088,11 @@ function get_user_preferences($name = null, $default = null, $user = null) {
|
|||
} else if (isset($user->id)) {
|
||||
// Is a valid object.
|
||||
} else if (is_numeric($user)) {
|
||||
$user = (object)array('id' => (int)$user);
|
||||
if ($USER->id == $user) {
|
||||
$user = $USER;
|
||||
} else {
|
||||
$user = (object)array('id' => (int)$user);
|
||||
}
|
||||
} else {
|
||||
throw new coding_exception('Invalid $user parameter in get_user_preferences() call');
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue