Skip to content

Commit

Permalink
Fix an issue with sessions
Browse files Browse the repository at this point in the history
  • Loading branch information
dragomano committed Mar 31, 2024
1 parent b6f09c9 commit ffdb617
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/Sources/LightPortal/Utils/SessionManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ public function getActiveBlocksCount(): int

public function getActivePagesCount(): int
{
if ($this->session('lp')->get('active_pages') === null) {
$key = Utils::$context['allow_light_portal_manage_pages_any'] ? '' : ('_u' . User::$info['id']);

if ($this->session('lp')->get('active_pages' . $key) === null) {
$result = Db::$db->query('', '
SELECT COUNT(page_id)
FROM {db_prefix}lp_pages
Expand All @@ -77,15 +79,17 @@ public function getActivePagesCount(): int

Db::$db->free_result($result);

$this->session('lp')->put('active_pages', (int) $count);
$this->session('lp')->put('active_pages' . $key, (int) $count);
}

return $this->session('lp')->get('active_pages') ?? 0;
return $this->session('lp')->get('active_pages' . $key) ?? 0;
}

public function getMyPagesCount(): int
{
if ($this->session('lp')->get('my_pages') === null) {
$key = Utils::$context['allow_light_portal_manage_pages_any'] ? '' : ('_u' . User::$info['id']);

if ($this->session('lp')->get('my_pages' . $key) === null) {
$result = Db::$db->query('', '
SELECT COUNT(page_id)
FROM {db_prefix}lp_pages
Expand All @@ -99,10 +103,10 @@ public function getMyPagesCount(): int

Db::$db->free_result($result);

$this->session('lp')->put('my_pages', (int) $count);
$this->session('lp')->put('my_pages' . $key, (int) $count);
}

return $this->session('lp')->get('my_pages') ?? 0;
return $this->session('lp')->get('my_pages' . $key) ?? 0;
}

public function getUnapprovedPagesCount(): int
Expand Down

0 comments on commit ffdb617

Please sign in to comment.