mirror of
https://github.com/moodle/moodle.git
synced 2025-03-14 12:40:01 +01:00
MDL-59595 admin: Make sure $ADMIN is properly unset when changing users
This commit is contained in:
parent
dbf66238b7
commit
7d91564204
@ -7971,9 +7971,7 @@ function admin_externalpage_setup($section, $extrabutton = '', array $extraurlpa
|
||||
* @return object admin_root object
|
||||
*/
|
||||
function admin_get_root($reload=false, $requirefulltree=true) {
|
||||
global $CFG, $DB, $OUTPUT;
|
||||
|
||||
static $ADMIN = NULL;
|
||||
global $CFG, $DB, $OUTPUT, $ADMIN;
|
||||
|
||||
if (is_null($ADMIN)) {
|
||||
// create the admin tree!
|
||||
|
@ -712,6 +712,7 @@ class manager {
|
||||
* @param \stdClass $user record
|
||||
*/
|
||||
public static function set_user(\stdClass $user) {
|
||||
global $ADMIN;
|
||||
$GLOBALS['USER'] = $user;
|
||||
unset($GLOBALS['USER']->description); // Conserve memory.
|
||||
unset($GLOBALS['USER']->password); // Improve security.
|
||||
@ -723,6 +724,9 @@ class manager {
|
||||
// Relink session with global $USER just in case it got unlinked somehow.
|
||||
$_SESSION['USER'] =& $GLOBALS['USER'];
|
||||
|
||||
// Nullify the $ADMIN tree global. If we're changing users, then this is now stale and must be generated again if needed.
|
||||
$ADMIN = null;
|
||||
|
||||
// Init session key.
|
||||
sesskey();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user