PaulB
Well-known member
- Affected version
- 2.2.1
Around line 55:
The callback function should return an integer: -1, 0, or 1 for less than, equal to, or greater than, respectively. As far as I'm aware, returning a boolean has never been officially supported and will likely result in incorrect or indeterminate sorting.
PHP 8.0 explicitly disallows this:
Repro by installing XFES on PHP 8.0.0 RC2.
PHP 7.0 introduced the spaceship operator (
Alternatively, for ascending order, swap the operands.
PHP:
uksort($sub, function($a, $b)
{
return strlen($a) < strlen($b);
});
The callback function should return an integer: -1, 0, or 1 for less than, equal to, or greater than, respectively. As far as I'm aware, returning a boolean has never been officially supported and will likely result in incorrect or indeterminate sorting.
PHP 8.0 explicitly disallows this:
Code:
ErrorException: [E_DEPRECATED] uksort(): Returning bool from comparison function is deprecated, return an integer less than, equal to, or greater than zero in src/XF/Repository/Route.php at line 60
Repro by installing XFES on PHP 8.0.0 RC2.
PHP 7.0 introduced the spaceship operator (
<=>
), which should be used here instead. Assuming you want descending order by string length:
PHP:
uksort($sub, function($a, $b)
{
return strlen($b) <=> strlen($a);
});
Alternatively, for ascending order, swap the operands.