From 8d7f6bc62bc8dbdc5b2b708ca50d0e38d93c124f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steffen=20Schro=CC=88der?= Date: Tue, 29 Jul 2014 00:00:07 +0200 Subject: [PATCH] stats fix for invalid custom callbacks --- application/core/Statistics/StatisticCollector.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/application/core/Statistics/StatisticCollector.php b/application/core/Statistics/StatisticCollector.php index ded001eb..8b41eac8 100644 --- a/application/core/Statistics/StatisticCollector.php +++ b/application/core/Statistics/StatisticCollector.php @@ -270,11 +270,12 @@ class StatisticCollector implements CallbackListener { break; case 'EndTurn': //TODO make it for other modes working $paramsObject = json_decode($callback[1][1]); - $durationTime = (int)(($paramsObject->EndTime - $paramsObject->StartTime) / 1000); - $scoresTable = $paramsObject->ScoresTable; - foreach ($scoresTable as $score) { - $player = $this->maniaControl->playerManager->getPlayer($score->Login); - $this->maniaControl->statisticManager->insertStat(self::STAT_PLAYTIME, $player, -1, $durationTime); + if ($paramsObject && is_array($paramsObject->ScoresTable)) { + $durationTime = (int)(($paramsObject->EndTime - $paramsObject->StartTime) / 1000); + foreach ($paramsObject->ScoresTable as $score) { + $player = $this->maniaControl->playerManager->getPlayer($score->Login); + $this->maniaControl->statisticManager->insertStat(self::STAT_PLAYTIME, $player, -1, $durationTime); + } } break; }