Skip to content

Commit

Permalink
MDL-32379: Fix memory leak in session_set_user
Browse files Browse the repository at this point in the history
session_set_user mistakingly sets the session user to be a reference to the passed object.

This is a problem when alot of data is attached to the session user object,
as any process holding a list of these users will use more memory each time it changes user.
  • Loading branch information
Tony Levi committed Apr 10, 2012
1 parent f24ff8f commit e71b08c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/sessionlib.php
Expand Up @@ -1067,7 +1067,7 @@ function get_moodle_cookie() {
* @return void
*/
function session_set_user($user) {
$_SESSION['USER'] = $user;
$_SESSION['USER'] = clone $user;
unset($_SESSION['USER']->description); // conserve memory
sesskey(); // init session key
}
Expand Down

0 comments on commit e71b08c

Please sign in to comment.