[wp-trac] [WordPress Trac] #57358: PHP 8 deprecation in wp-includes/category-template.php uasort() helper

WordPress Trac noreply at wordpress.org
Mon Dec 19 17:53:44 UTC 2022


#57358: PHP 8 deprecation in wp-includes/category-template.php uasort() helper
-------------------------+-----------------------------
 Reporter:  Webrocker    |      Owner:  (none)
     Type:  enhancement  |     Status:  new
 Priority:  normal       |  Milestone:  Awaiting Review
Component:  General      |    Version:  6.1.1
 Severity:  normal       |   Keywords:
  Focuses:               |
-------------------------+-----------------------------
 category-template.php, line 1089 ff:

 {{{#!php
 function _wp_object_count_sort_cb( $a, $b ) {
         return ( $a->count > $b->count );
 }
 }}}

 This throws a Deprecation warning with PHP 8: "Deprecated: uasort():
 Returning bool from comparison function is deprecated, return an integer
 less than, equal to, or greater than zero in `wp-includes/category-
 template.php`

 changing the above code to

 {{{#!php
 function _wp_object_count_sort_cb( $a, $b ) {
         return ( $a->count - $b->count );
 }
 }}}

 fixes the warning for me, while still sorting as before.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/57358>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list