Skip to content

Commit

Permalink
[ticket/16470] Do not sync user last visit time with expired sessions…
Browse files Browse the repository at this point in the history
… time

PHPBB3-16470
PHPBB3-14173
  • Loading branch information
rxu committed Jun 20, 2023
1 parent bbe2b21 commit 735b826
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions phpBB/phpbb/session.php
Original file line number Diff line number Diff line change
Expand Up @@ -960,17 +960,16 @@ function session_gc()
}

/**
* Get expired sessions for registered users, only most recent for each user
* Inner SELECT gets most recent expired sessions for unique session_user_id
* Get most recent session for each registered user to sync user last visit with it
* Inner SELECT gets most recent sessions for each unique session_user_id
* Outer SELECT gets data for them
*/
$sql_select = 'SELECT s1.session_page, s1.session_user_id, s1.session_time AS recent_time
FROM ' . SESSIONS_TABLE . ' AS s1
INNER JOIN (
SELECT session_user_id, MAX(session_time) AS recent_time
FROM ' . SESSIONS_TABLE . '
WHERE session_time < ' . ($this->time_now - (int) $config['session_length']) . '
AND session_user_id <> ' . ANONYMOUS . '
WHERE session_user_id <> ' . ANONYMOUS . '
GROUP BY session_user_id
) AS s2
ON s1.session_user_id = s2.session_user_id
Expand Down

0 comments on commit 735b826

Please sign in to comment.