Closed izmeez closed 1 year ago
I cannot reproduce this, @izmeez. What exactly do you do to get this error?
Using this type of comparison in PHP 8.1 WILL produce the deprecated message:
uasort($files, function($a, $b) {return ($a->filemtime < $b->filemtime);});
The problem here is that the <
comparison returns a boolean, and uasort()
will only accept ints such as 1, 0 or -1.
Typically you would fix this with the "spaceship" operator (<=>
), BUT it doesn't work in PHP 5.6, which is still supported by Backdrop
So, the only possible solution is:
[EDITED]
uasort($files, function($a, $b) {
return ($a->filemtime == $b->filemtime) ? 0 : (($a->filemtime < $b->filemtime) ? 1 : -1);
});
Sorry, there are some inaccuracies in my answer. I'll edit soon.
[EDIT]: I fixed the answer above.
@argiepiano, I understand the problem. I will fix it with your code. However, I'm not getting any error on php 8.1.20. at least on Backdrop's log.
@izmeez, as I cannot reproduce the error, would you check the pr for this fix? Thanks.
Yes, the fix works with php 8.1.17
With php 8.1.17 the following error message appears:
Deprecated function: uasort(): Returning bool from comparison function is deprecated, return an integer less than, equal to, or greater than zero in demo_get_dumps() (line 497 of .../demo.admin.inc).