MDL-46099 session: fix use of references for session globals
This reverses the references used for global $USER and $SESSION, the reason is that PHP does not allow references to references. $USER is a reference to $GLOBALS['USER'] which means we cannot put any references to it. Solution is to store the current user and session objects in $GLOBALS['USER'] and $GLOBALS['SESSIOn'] are reference them in $_SESSION. This patch makes the session code behave the same way in CLI, phpunit and normal web requests - this allows use to finally unit test most aspects of the session code in Moodle.
This commit is contained in:
@@ -773,10 +773,6 @@ if (empty($CFG->sessiontimeout)) {
|
||||
$CFG->sessiontimeout = 7200;
|
||||
}
|
||||
\core\session\manager::start();
|
||||
if (!PHPUNIT_TEST and !defined('BEHAT_TEST')) {
|
||||
$SESSION =& $_SESSION['SESSION'];
|
||||
$USER =& $_SESSION['USER'];
|
||||
}
|
||||
|
||||
// Initialise some variables that are supposed to be set in config.php only.
|
||||
if (!isset($CFG->filelifetime)) {
|
||||
|
||||
Reference in New Issue
Block a user