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
In the sportspress/includes/class-sp-league-table.php file, lines 911 and 917, uasort expects 0 or 1 or -1, thus simply returning the value difference will give inconsistent results.
How to reproduce:
Create a new league table, use a column with decimal places then add a difference smaller than 1 between items:
e.g
Team A: 5.28
Team B: 6.27
The ordering will be broken, because the function returns -0.99 instead of -1.
How to fix it:
A simple one line conditional statement should do it: return ( (float) $b[ $this->orderby ] - (float) $a[ $this->orderby ] ) > 0 ? 1 : -1;
In the sportspress/includes/class-sp-league-table.php file, lines 911 and 917, uasort expects 0 or 1 or -1, thus simply returning the value difference will give inconsistent results.
How to reproduce:
Create a new league table, use a column with decimal places then add a difference smaller than 1 between items:
e.g
Team A: 5.28
Team B: 6.27
The ordering will be broken, because the function returns -0.99 instead of -1.
How to fix it:
A simple one line conditional statement should do it:
return ( (float) $b[ $this->orderby ] - (float) $a[ $this->orderby ] ) > 0 ? 1 : -1;
and
return ( (float) $a[ $this->orderby ] - (float) $b[ $this->orderby ] ) > 0 ? 1 : -1;
At least this fixes the issue for me. Cheers!
The text was updated successfully, but these errors were encountered: