From ec10223528124078b26ec86174b441453e679f30 Mon Sep 17 00:00:00 2001 From: Yury Pikhtarev Date: Wed, 18 Jun 2025 12:41:01 +0400 Subject: [PATCH] fix(User): add null and array checks before session data operations Ensure that session data is only processed if it exists and is an array. This prevents potential errors when attempting to cache or remove user session data. Updated methods `cache_set_userdata` and `cache_rm_userdata` to include necessary checks. --- src/Legacy/Common/User.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/Legacy/Common/User.php b/src/Legacy/Common/User.php index f5738083e..e76ca3a28 100644 --- a/src/Legacy/Common/User.php +++ b/src/Legacy/Common/User.php @@ -151,7 +151,9 @@ class User $update_sessions_table = true; } - Sessions::cache_set_userdata($this->data); + if ($this->data) { + Sessions::cache_set_userdata($this->data); + } } } @@ -335,11 +337,13 @@ class User */ public function session_end(bool $update_lastvisit = false, bool $set_cookie = true) { - Sessions::cache_rm_userdata($this->data); - DB()->query(" - DELETE FROM " . BB_SESSIONS . " - WHERE session_id = '{$this->data['session_id']}' - "); + if ($this->data && is_array($this->data)) { + Sessions::cache_rm_userdata($this->data); + DB()->query(" + DELETE FROM " . BB_SESSIONS . " + WHERE session_id = '{$this->data['session_id']}' + "); + } if (!IS_GUEST) { if ($update_lastvisit) {