MDL-79092 session: fix recentsessionlocks mutated session debugging

In write_close() call update_recent_session_locks() before setting
$sessionatclose so that it includes $SESSION->recentsessionlocks and
doesn't trigger the debugging in check_mutated_closed_session().
This commit is contained in:
Rossco Hellmans
2023-08-23 09:29:34 +10:00
parent cccc00954d
commit d0385ed705
+6 -6
View File
@@ -689,12 +689,6 @@ class manager {
global $PERF, $ME, $CFG;
if (self::$sessionactive) {
// If debugging, take a snapshot of session at close and compare on shutdown to detect any accidental mutations.
if (debugging()) {
self::$sessionatclose = (array) $_SESSION['SESSION'];
\core_shutdown_manager::register_function('\core\session\manager::check_mutated_closed_session');
}
// Grab the time when session lock is released.
$PERF->sessionlock['released'] = microtime(true);
if (!empty($PERF->sessionlock['gained'])) {
@@ -704,6 +698,12 @@ class manager {
self::update_recent_session_locks($PERF->sessionlock);
self::sessionlock_debugging();
// If debugging, take a snapshot of session at close and compare on shutdown to detect any accidental mutations.
if (debugging()) {
self::$sessionatclose = (array) $_SESSION['SESSION'];
\core_shutdown_manager::register_function('\core\session\manager::check_mutated_closed_session');
}
$requireslock = self::$handler->requires_write_lock();
if (!$requireslock || !self::$requireslockdebug) {
// Compare the array of the earlier session data with the array now, if