mirror of
https://github.com/moodle/moodle.git
synced 2025-08-06 17:36:38 +02:00
MDL-64452 cache: Always use the current session id in the key prefix
The current logic in the cache_session::check_tracked_user() is not right. We must always set the current session id. A typical use case is when the cache instance is instantiated for a not logged in user. We can't let the sessionid property null in that case as it forms an important part of the parsed key. Similarly, even if we have the same user currently loaded, we must still set the sessionid to make sure the data will be associated with the current PHP session. Same user (including visitors or guest users) can access the site from different browsers and each must end up with its own key prefix.
This commit is contained in:
parent
41a15e6d73
commit
c4f137749d
1 changed files with 1 additions and 4 deletions
5
cache/classes/loaders.php
vendored
5
cache/classes/loaders.php
vendored
|
@ -1712,6 +1712,7 @@ class cache_session extends cache {
|
|||
public function __construct(cache_definition $definition, cache_store $store, $loader = null) {
|
||||
// First up copy the loadeduserid to the current user id.
|
||||
$this->currentuserid = self::$loadeduserid;
|
||||
$this->set_session_id();
|
||||
parent::__construct($definition, $store, $loader);
|
||||
|
||||
// This will trigger check tracked user. If this gets removed a call to that will need to be added here in its place.
|
||||
|
@ -1771,8 +1772,6 @@ class cache_session extends cache {
|
|||
// Purge the data we have for the old user.
|
||||
// This way we don't bloat the session.
|
||||
$this->purge();
|
||||
// Update the session id just in case!
|
||||
$this->set_session_id();
|
||||
}
|
||||
self::$loadeduserid = $new;
|
||||
$this->currentuserid = $new;
|
||||
|
@ -1780,8 +1779,6 @@ class cache_session extends cache {
|
|||
// The current user matches the loaded user but not the user last used by this cache.
|
||||
$this->purge_current_user();
|
||||
$this->currentuserid = $new;
|
||||
// Update the session id just in case!
|
||||
$this->set_session_id();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue