Add a limit of 1000 when pulling sessions. Sessions table can contain hundreds of thousands of lines all relatively useless. Modals need to pop up fast.

This commit is contained in:
Isaac Connor 2021-06-12 11:57:10 -04:00
parent b634338398
commit 3141ec32fe
1 changed files with 9 additions and 10 deletions

View File

@ -43,8 +43,8 @@ global $CLANG;
<tbody>
<?php
require_once('includes/User.php');
$result = dbQuery('SELECT * FROM Sessions ORDER BY access DESC');
if ( ! $result ) return;
$result = dbQuery('SELECT * FROM Sessions ORDER BY access DESC LIMIT 1000');
if (!$result) return;
$current_session = $_SESSION;
zm_session_start();
@ -52,25 +52,24 @@ zm_session_start();
$user_cache = array();
while ( $row = $result->fetch(PDO::FETCH_ASSOC) ) {
$_SESSION = array();
if ( ! session_decode($row['data']) ) {
ZM\Warning('Failed to decode ' . $row['data']);
if (!session_decode($row['data'])) {
ZM\Warning('Failed to decode '.$row['data']);
continue;
}
ZM\Debug(print_r($_SESSION, true));
if ( isset($_SESSION['last_time']) ) {
if (isset($_SESSION['last_time'])) {
# This is a dead session
continue;
}
if ( !isset($_SESSION['username']) ) {
if (!isset($_SESSION['username'])) {
# Not logged in
continue;
}
if ( isset($user_cache[$_SESSION['username']]) ) {
if (isset($user_cache[$_SESSION['username']])) {
$user = $user_cache[$_SESSION['username']];
} else {
$user = ZM\User::find_one(array('Username'=>$_SESSION['username']));
if ( ! $user ) {
ZM\Debug('User not found for ' . $_SESSION['username']);
if (!$user) {
ZM\Debug('User not found for '.$_SESSION['username']);
continue;
}
$user_cache[$_SESSION['username']] = $user;