Skip to content

Commit

Permalink
Merge branch '3.3.x'
Browse files Browse the repository at this point in the history
  • Loading branch information
marc1706 committed Aug 1, 2024
2 parents d3be916 + b7ffee0 commit b60c2fe
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions phpBB/phpbb/session.php
Original file line number Diff line number Diff line change
Expand Up @@ -832,7 +832,7 @@ function session_create($user_id = false, $set_admin = false, $persist_login = f
// Update the form key
$sql = 'UPDATE ' . USERS_TABLE . '
SET user_form_salt = \'' . $db->sql_escape($this->data['user_form_salt']) . '\',
user_last_active = ' . (int) $this->data['session_time'] . '
user_last_active = ' . (int) $this->time_now . '
WHERE user_id = ' . (int) $this->data['user_id'];
$db->sql_query($sql);
}
Expand Down Expand Up @@ -980,16 +980,17 @@ function session_gc()
}

/**
* 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
* Get expired sessions for registered users, only most recent for each user
* Inner SELECT gets most recent expired sessions for 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_user_id <> ' . ANONYMOUS . '
WHERE session_time < ' . ($this->time_now - (int) $config['session_length']) . '
AND 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 b60c2fe

Please sign in to comment.