From 49c4cfb2d5faefbc4dd7b531f8552f15f7a4bc4f Mon Sep 17 00:00:00 2001 From: Matthew Hilton Date: Fri, 16 Sep 2022 10:37:34 +1000 Subject: [PATCH] MDL-73317 restore: Reset navcache before closing session As part of a restore, the session is closed early so it does not interrupt the users session during the restore. Currently the restore controller rebuilds the course caches while restoring. This inadvertently resets the navcache, which would edit the session despite it being closed. Because this tracker now adds logging for this behaviour, it means restoring now outputs a debugging message as a warning. To resolve the debugging message, the navcache is now reset just before closing the session. This is allowed, since the caches are designed to be volatile. --- backup/controller/restore_controller.class.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/backup/controller/restore_controller.class.php b/backup/controller/restore_controller.class.php index 0e60d08d53a..61032de826a 100644 --- a/backup/controller/restore_controller.class.php +++ b/backup/controller/restore_controller.class.php @@ -384,6 +384,9 @@ class restore_controller extends base_controller { // Release the session so other tabs in the same session are not blocked. if ($this->get_releasesession() === backup::RELEASESESSION_YES) { + // Preemptively reset the navcache before closing, so it remains the same on shutdown. + navigation_cache::destroy_volatile_caches(); + \core\session\manager::write_close(); }