fix(preferences): refresh session cache so saved prefs show immediately [#198]

userinfo is served from a 30s session cache (Session::PopulateVar), so a
freshly saved preference (e.g. the large-map checkbox) only reflected after
the cache expired or a re-login — the box appeared unchanged on OK.

Invalidate the per-user session cache after saving so the redirected page
reloads the values from the DB right away.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Ferywir
2026-06-11 17:08:54 +02:00
committed by Catalin Novgorodschi
parent c2d8e74859
commit 9d88727aff
+4 -8
View File
@@ -91,14 +91,10 @@ class Profile {
"WHERE id=" . (int)$session->uid
);
// Keep the in-memory session in sync for the immediate re-render.
foreach ([
'v1' => $v1, 'v2' => $v2, 'v3' => $v3, 'map' => $map,
'v4' => $v4, 'v5' => $v5, 'v6' => $v6,
'timezone' => $timezone, 'tformat' => $tformat,
] as $field => $value) {
$session->userinfo[$field] = $value;
}
// Invalidate the 30s session user-cache (see Session::PopulateVar) so the
// reloaded page reflects the new values immediately, without a re-login.
$cacheKeyUser = 'cache_user_' . ($_SESSION['username'] ?? '');
unset($_SESSION[$cacheKeyUser]);
// Game language.
$allowed = ['en', 'fr', 'it', 'ro', 'zh'];