Fix highscores error

This commit is contained in:
slawkens 2023-11-09 20:32:20 +01:00
parent 9d119b6279
commit a04fbde607

View File

@ -135,6 +135,7 @@ if($settingHighscoresOutfit) {
$configHighscoresPerPage = setting('core.highscores_per_page'); $configHighscoresPerPage = setting('core.highscores_per_page');
$limit = $configHighscoresPerPage + 1; $limit = $configHighscoresPerPage + 1;
$highscores = [];
$needReCache = true; $needReCache = true;
$cacheKey = 'highscores_' . $skill . '_' . $vocation . '_' . $page . '_' . $configHighscoresPerPage; $cacheKey = 'highscores_' . $skill . '_' . $vocation . '_' . $page . '_' . $configHighscoresPerPage;
@ -158,7 +159,7 @@ $query->join('accounts', 'accounts.id', '=', 'players.account_id')
->selectRaw('accounts.country, players.id, players.name, players.account_id, players.level, players.vocation' . $outfit . $promotion) ->selectRaw('accounts.country, players.id, players.name, players.account_id, players.level, players.vocation' . $outfit . $promotion)
->orderByDesc('value'); ->orderByDesc('value');
if (!isset($highscores) || empty($highscores)) { if (empty($highscores)) {
if ($skill >= POT::SKILL_FIRST && $skill <= POT::SKILL_LAST) { // skills if ($skill >= POT::SKILL_FIRST && $skill <= POT::SKILL_LAST) { // skills
if ($db->hasColumn('players', 'skill_fist')) {// tfs 1.0 if ($db->hasColumn('players', 'skill_fist')) {// tfs 1.0
$skill_ids = array( $skill_ids = array(
@ -201,16 +202,16 @@ if (!isset($highscores) || empty($highscores)) {
$list = 'experience'; $list = 'experience';
} }
} }
}
$highscores = $query->get()->map(function($row) { $highscores = $query->get()->map(function($row) {
$tmp = $row->toArray(); $tmp = $row->toArray();
$tmp['online'] = $row->online_status; $tmp['online'] = $row->online_status;
$tmp['vocation'] = $row->vocation_name; $tmp['vocation'] = $row->vocation_name;
unset($tmp['online_table']); unset($tmp['online_table']);
return $tmp; return $tmp;
})->toArray(); })->toArray();
}
if ($cache->enabled() && $needReCache) { if ($cache->enabled() && $needReCache) {
$cache->set($cacheKey, serialize($highscores), setting('core.highscores_cache_ttl') * 60); $cache->set($cacheKey, serialize($highscores), setting('core.highscores_cache_ttl') * 60);