From f599e08586aade2342c6775daf0e92f944f2cd80 Mon Sep 17 00:00:00 2001 From: Martin Ambrus Date: Sat, 25 Nov 2017 00:45:33 +0100 Subject: [PATCH] fix: wrong non-multi-array caching of getMovement caused a lot of error #377 --- GameEngine/Database.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/GameEngine/Database.php b/GameEngine/Database.php index d014aaf0..5923340a 100755 --- a/GameEngine/Database.php +++ b/GameEngine/Database.php @@ -5275,7 +5275,7 @@ References: User ID/Message ID, Mode // first of all, check if we should be using cache and whether the field // required is already cached if ($use_cache && !$array_passed && isset(self::$marketMovementCache[$type.$village[0].$mode]) && is_array(self::$marketMovementCache[$type.$village[0].$mode]) && !count(self::$marketMovementCache[$type.$village[0].$mode])) { - return []; + return self::$marketMovementCache[$type.$village[0].$mode]; } else if ($use_cache && $array_passed) { // check what we can return from cache $newIDs = []; @@ -5294,7 +5294,7 @@ References: User ID/Message ID, Mode } } else if ($use_cache && !$array_passed && ($cachedValue = self::returnCachedContent(self::$marketMovementCache, $type.$village[0].$mode)) && !is_null($cachedValue)) { // special case when we have empty arrays cached for this cache only - return ($array_passed ? self::$marketMovementCache : [$cachedValue]); + return ($array_passed ? self::$marketMovementCache: $cachedValue); } $time = time(); @@ -5347,7 +5347,7 @@ References: User ID/Message ID, Mode } else { if ($result && count($result)) { foreach ( $result as $record ) { - self::$marketMovementCache[ $type . $record[ $where ] . $mode ] = $record; + self::$marketMovementCache[ $type . $record[ $where ] . $mode ][] = $record; } } @@ -5802,7 +5802,7 @@ References: User ID/Message ID, Mode // first of all, check if we should be using cache and whether the field // required is already cached if ($use_cache && !$array_passed && isset(self::$abTechCache[$vid[0]]) && is_array(self::$abTechCache[$vid[0]]) && !count(self::$abTechCache[$vid[0]])) { - return []; + return self::$abTechCache[$vid[0]]; } else if ($use_cache && $array_passed) { // check what we can return from cache $newVIDs = []; @@ -6127,7 +6127,7 @@ References: User ID/Message ID, Mode // first of all, check if we should be using cache and whether the field // required is already cached if ($use_cache && !$array_passed && isset(self::$oasisReinforcementsCache[$ref[0].$mode]) && is_array(self::$oasisReinforcementsCache[$ref[0].$mode]) && !count(self::$oasisReinforcementsCache[$ref[0].$mode])) { - return []; + return self::$oasisReinforcementsCache[$ref[0].$mode]; } else if ($use_cache && $array_passed) { // check what we can return from cache $newREFs = []; @@ -6346,7 +6346,7 @@ References: User ID/Message ID, Mode // first of all, check if we should be using cache and whether the field // required is already cached if ($use_cache && !$array_passed && isset(self::$villageReinforcementsCache[$id[0].$mode]) && is_array(self::$villageReinforcementsCache[$id[0].$mode]) && !count(self::$villageReinforcementsCache[$id[0].$mode])) { - return []; + return self::$villageReinforcementsCache[$id[0].$mode]; } else if ($use_cache && $array_passed) { // check what we can return from cache $newIDs = []; @@ -7359,7 +7359,7 @@ References: User ID/Message ID, Mode // first of all, check if we should be using cache and whether the field // required is already cached if ($use_cache && !$array_passed && isset(self::$prisonersCache[$wid[0].$mode]) && is_array(self::$prisonersCache[$wid[0].$mode]) && !count(self::$prisonersCache[$wid[0].$mode])) { - return []; + return self::$prisonersCache[$wid[0].$mode]; } else if ($use_cache && $array_passed) { // check what we can return from cache $newWIDs = [];