You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When requesting any leaderboard with before > 0, the returned range of leaderboard positions is incorrect. Using e.g. pos=5&before=2&after=2, one should receive a total of five entries (position itself, two before, two after). However, only three positions are returned (position itself, two before).
The bug is caused by max = after + 1 being treated as an absolute position index (similar to min = (pos - 1) - before), when it is actually used as the number of items to return in the LIMIT statement (where min = (pos - 1) - before acts as the OFFSET).
$query = "SELECT id, name, rank_id, country, time, score FROM player WHERE score > 0
ORDER BY score DESC, name DESC LIMIT " . $min . ", " . $max;
The correct way to calculate max would be max = position + after - min. In the above example, min = (pos 5 - 1) - before 2 would result in OFFSET 2 and max = position 5 + after 2 - min 2 would set LIMIT 5.
The text was updated successfully, but these errors were encountered:
When requesting any leaderboard with
before > 0
, the returned range of leaderboard positions is incorrect. Using e.g.pos=5&before=2&after=2
, one should receive a total of five entries (position itself, two before, two after). However, only three positions are returned (position itself, two before).The bug is caused by
max = after + 1
being treated as an absolute position index (similar tomin = (pos - 1) - before
), when it is actually used as the number of items to return in theLIMIT
statement (wheremin = (pos - 1) - before
acts as theOFFSET
).asp/src/ASP/aspx/getleaderboard.php
Lines 81 to 90 in df86f71
asp/src/ASP/aspx/getleaderboard.php
Lines 121 to 122 in df86f71
The correct way to calculate
max
would bemax = position + after - min
. In the above example,min = (pos 5 - 1) - before 2
would result inOFFSET 2
andmax = position 5 + after 2 - min 2
would setLIMIT 5
.The text was updated successfully, but these errors were encountered: