From 83955eddbf068e12cadaccd7a14c3b07a3930a8c Mon Sep 17 00:00:00 2001 From: Shawn Bulen Date: Sun, 15 Mar 2026 12:00:49 -0700 Subject: [PATCH 1/3] Minimize unnecessary session writes Signed-off-by: Shawn Bulen --- Sources/Session.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Sources/Session.php b/Sources/Session.php index 1f57cf7d6c..12d1820248 100644 --- a/Sources/Session.php +++ b/Sources/Session.php @@ -100,6 +100,12 @@ public function write(string $session_id, string $data): bool return true; } + // Don't bother writing the session for users just browsing + // If verification is required, always write the session + if ((empty($_REQUEST['action']) || in_array($_REQUEST['action'], $no_writes, true)) && !empty(Config::$scripturl) && empty(Utils::$context['require_verification'])) { + return true; + } + if (preg_match('~^[A-Za-z0-9,-]{16,64}$~', $session_id) == 0) { return false; } From 6821fcfecb94c0f1b32bf02672cb7ccab0c26e04 Mon Sep 17 00:00:00 2001 From: Shawn Bulen Date: Sun, 15 Mar 2026 12:09:41 -0700 Subject: [PATCH 2/3] Minimize unnecessary session writes Signed-off-by: Shawn Bulen --- Sources/Session.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Sources/Session.php b/Sources/Session.php index 12d1820248..cbeb731358 100644 --- a/Sources/Session.php +++ b/Sources/Session.php @@ -95,6 +95,9 @@ public function read(string $session_id): string */ public function write(string $session_id, string $data): bool { + // Any action that is not dependent on data within the session may be added to this array + static $no_writes = array('dlattach'); + // Don't bother writing the session if cookies are disabled if (empty($_COOKIE)) { return true; From e7e1d5bafa8bbc3b2f3771d490942ca3cfa5a72b Mon Sep 17 00:00:00 2001 From: Shawn Bulen Date: Sun, 15 Mar 2026 12:13:33 -0700 Subject: [PATCH 3/3] Minimize unnecessary session writes Signed-off-by: Shawn Bulen --- Sources/Session.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sources/Session.php b/Sources/Session.php index cbeb731358..415e8d6567 100644 --- a/Sources/Session.php +++ b/Sources/Session.php @@ -96,7 +96,7 @@ public function read(string $session_id): string public function write(string $session_id, string $data): bool { // Any action that is not dependent on data within the session may be added to this array - static $no_writes = array('dlattach'); + static $no_writes = ['dlattach']; // Don't bother writing the session if cookies are disabled if (empty($_COOKIE)) { @@ -105,7 +105,7 @@ public function write(string $session_id, string $data): bool // Don't bother writing the session for users just browsing // If verification is required, always write the session - if ((empty($_REQUEST['action']) || in_array($_REQUEST['action'], $no_writes, true)) && !empty(Config::$scripturl) && empty(Utils::$context['require_verification'])) { + if ((empty($_REQUEST['action']) || \in_array($_REQUEST['action'], $no_writes, true)) && !empty(Config::$scripturl) && empty(Utils::$context['require_verification'])) { return true; }