Skip to content

Commit

Permalink
SmrSession: remove references in for loops
Browse files Browse the repository at this point in the history
See #317.
  • Loading branch information
hemberger committed Mar 28, 2021
1 parent 65d20ce commit 2b5828b
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/lib/Default/SmrSession.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -243,20 +243,20 @@ public static function fetchVarInfo() {
self::$game_id = 0;
self::$var = array();
} else {
foreach (self::$var as $key => &$value) {
foreach (self::$var as $key => $value) {
if ($value['Expires'] > 0 && $value['Expires'] <= self::getTime()) { // Use 0 for infinity
//This link is no longer valid
unset(self::$var[$key]);
} elseif ($value['RemainingPageLoads'] < 0) {
//This link is no longer valid
unset(self::$var[$key]);
} else {
--$value['RemainingPageLoads'];
--self::$var[$key]['RemainingPageLoads'];
if (isset($value['CommonID'])) {
self::$commonIDs[$value['CommonID']] = $key;
}
}
} unset($value);
}
}
} else {
self::$generate = true;
Expand All @@ -268,12 +268,12 @@ public static function fetchVarInfo() {
}

public static function update() {
foreach (self::$var as $key => &$value) {
foreach (self::$var as $key => $value) {
if ($value['RemainingPageLoads'] <= 0) {
//This link was valid this load but will not be in the future, removing it now saves database space and data transfer.
unset(self::$var[$key]);
}
} unset($value);
}
$compressed = gzcompress(serialize(self::$var));
if (!self::$generate) {
self::$db->query('UPDATE active_session SET account_id=' . self::$db->escapeNumber(self::$account_id) . ',game_id=' . self::$db->escapeNumber(self::$game_id) . (!USING_AJAX ? ',last_accessed=' . self::$db->escapeNumber(self::getTime()) : '') . ',session_var=' . self::$db->escapeBinary($compressed) .
Expand Down

0 comments on commit 2b5828b

Please sign in to comment.