fix(User): add null and array checks before session data operations (#1962)

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.
This commit is contained in:
Yury Pikhtarev 2025-06-18 12:43:58 +04:00 committed by GitHub
commit e458109eef
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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) {