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