From 9d88727aff1ad2cd993dfee87f4d12b03d12bb11 Mon Sep 17 00:00:00 2001 From: Ferywir Date: Thu, 11 Jun 2026 17:08:54 +0200 Subject: [PATCH] fix(preferences): refresh session cache so saved prefs show immediately [#198] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- GameEngine/Profile.php | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/GameEngine/Profile.php b/GameEngine/Profile.php index 200e5c18..054540cb 100755 --- a/GameEngine/Profile.php +++ b/GameEngine/Profile.php @@ -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'];