Skip to content

Commit

Permalink
Add check to prevent online guests query before upgrade script is run
Browse files Browse the repository at this point in the history
  • Loading branch information
samerton committed Jan 5, 2020
1 parent 8cf093e commit 5129bca
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions modules/Core/widgets/StatsWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,14 @@ public function initialise(){
}

if(!$this->_cache->isCached('online_guests')){
$online_guests = DB::getInstance()->query('SELECT count(*) FROM nl2_online_guests WHERE last_seen > ?', array(strtotime('-5 minutes')))->first();
$online_guests = $online_guests->{'count(*)'};
$this->_cache->store('online_guests', $online_guests, 60);
try {
$online_guests = DB::getInstance()->query('SELECT count(*) FROM nl2_online_guests WHERE last_seen > ?', array(strtotime('-5 minutes')))->first();
$online_guests = $online_guests->{'count(*)'};
$this->_cache->store('online_guests', $online_guests, 60);
} catch(Exception $e){
// Upgrade script hasn't been run
$online_guests = 0;
}
} else {
$online_guests = $this->_cache->retrieve('online_guests');
}
Expand Down

0 comments on commit 5129bca

Please sign in to comment.