mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-22 06:13:58 -07:00
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.
This commit is contained in:
parent
f50b914cc1
commit
ec10223528
1 changed files with 10 additions and 6 deletions
|
@ -151,9 +151,11 @@ class User
|
|||
$update_sessions_table = true;
|
||||
}
|
||||
|
||||
if ($this->data) {
|
||||
Sessions::cache_set_userdata($this->data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Did the session exist in the DB?
|
||||
if ($this->data) {
|
||||
|
@ -335,11 +337,13 @@ class User
|
|||
*/
|
||||
public function session_end(bool $update_lastvisit = false, bool $set_cookie = true)
|
||||
{
|
||||
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