Maybe this bug has already been reported, but with 250+ pages to search through, I thought I would try this...
So the bug is this: When someone matches the high score for a game, the arcade homepage will sometimes show the wrong trophy holder. It appears the query to select the current champ is a bit flawed as it queries only for the highest score, and if it finds two or more, will sometimes select the wrong person (ie. The person who did not get the high score first.)
The bug appears to be in this code block in the arcade.php file:
PHP Code:
// While loop, where part of an SQL query is constructed
while ($thesession = $DB_site->fetch_array($result_topscores))
{
$where[] = "(gamename='$thesession[gamename]' AND score='$thesession[score]')";
$playedcounter[$thesession[gamename]] = $thesession['played'];
}
$DB_site->free_result($result_topscores);
// Query built
if(!empty($where)) {
$whereclause = "WHERE ".implode(' OR ', $where);
}
// Query to get the other data for the high scores
$result_topscore2 = $DB_site->query("
SELECT gamesessions.*, user.username, user.userid, games.*, games.title AS title FROM " . TABLE_PREFIX . "gamesessions AS gamesessions
LEFT JOIN " . TABLE_PREFIX . "user AS user ON user.userid = gamesessions.userid
LEFT JOIN " . TABLE_PREFIX . "games AS games ON gamesessions.gamename = games.shortname
$whereclause AND $sessionclause ORDER BY gamesessions.gamename DESC
");
This query needs to be modified to search for the high score AND the lowest final session time (final). I lack the SQL skill to get this done, can anyone help out here?
Thank you!