Permalink
Browse files

MDL-32379: Fix memory leak in session_set_user

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...
1 parent 4b3ee4f commit 3e86502dba186ef880980035c8b17707538147e7 @tlevi tlevi committed Apr 10, 2012
Showing with 1 addition and 1 deletion.
  1. +1 −1 lib/sessionlib.php
View
@@ -867,7 +867,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
if (!isset($_SESSION['USER']->access)) {
// check enrolments and load caps only once

0 comments on commit 3e86502

Please sign in to comment.