From 578d35e81f2fda2732865a86c9af3d486f8cf1a3 Mon Sep 17 00:00:00 2001 From: Mark Johnson Date: Wed, 10 Apr 2024 15:03:48 +0100 Subject: [PATCH] MDL-81192 sessions: Prevent false positive session change errors If $CFG->enable_read_only_sessions_debug was not enabled, debugging could be enabled part-way through a request when restart_with_write_lock was called. This meant that a diff between the initial and final session would be made during write_close(), although the intial session state was never captured. This generated false positives in the logs, and it thought any variable set in the session was a change from the original value. This ensures that debugging is enabled before the debug flag is allowed to change, preventing false positives. --- lib/classes/session/manager.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/classes/session/manager.php b/lib/classes/session/manager.php index 972a7435837..8b8f9e6a842 100644 --- a/lib/classes/session/manager.php +++ b/lib/classes/session/manager.php @@ -89,7 +89,9 @@ class manager { public static function restart_with_write_lock(bool $readonlysession) { global $CFG; - self::$requireslockdebug = !$readonlysession; + if (!empty($CFG->enable_read_only_sessions_debug)) { + self::$requireslockdebug = !$readonlysession; + } if (self::$sessionactive && !self::$handler->requires_write_lock()) { @self::$handler->abort();