mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-14 18:48:21 -07:00
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:
parent
f50b914cc1
commit
e458109eef
1 changed files with 10 additions and 6 deletions
|
@ -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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue