[wp-trac] [WordPress Trac] #57839: Coding Standards fixes for WP 6.3

WordPress Trac noreply at wordpress.org
Wed Jul 5 11:21:38 UTC 2023


#57839: Coding Standards fixes for WP 6.3
--------------------------------------+-------------------------------
 Reporter:  hellofromTonya            |       Owner:  (none)
     Type:  task (blessed)            |      Status:  new
 Priority:  normal                    |   Milestone:  6.3
Component:  General                   |     Version:
 Severity:  normal                    |  Resolution:
 Keywords:  has-patch has-unit-tests  |     Focuses:  coding-standards
--------------------------------------+-------------------------------

Comment (by SergeyBiryukov):

 Replying to [comment:63 jeremyfelt]:
 > Just a heads up: The [https://github.com/WordPress/wordpress-
 develop/blob/9fe8cdf1264c1ab87ef234219aa3633cd5e7d3b2/src/wp-includes
 /class-wp-list-util.php#L124 strict comparison] added to
 `WP_List_Util::filter` via [55908] broke a test on a project I maintain.
 >
 > {{{
 > // $created contains objects with maybe property disabled === '0'
 > $active = wp_filter_object_list( $created, [ 'disabled' => 0 ] );

 Replying to [comment:70 david.binda]:
 > Having the r55908 deployed on the WordPress.com revealed that the change
 may easily affect any code which has been (unintentionally) relying on
 type juggling when using the `wp_list_filter` function (in our case, it's
 been a string vs. int type juggling which got broken with the strict
 comparison).

 Good catch, thanks!

 Replying to [comment:71 azaozz]:
 > Yea, seems [55908] introduced a regression in `WP_List_Util::filter()`.
 That function was doing loose comparison (no documentation about the types
 too), and now the way it works has changed.
 >
 > Wondering if this change "can get away with" casting to strings before
 comparing. Seems int is also a valid key and/or value type there too.

 Seems reasonable, we already do that in a few other places, e.g.
 `__checked_selected_helper()`. But [56137] caused a few `Array to string
 conversion` warnings in `wp_filter_object_list()`, so restoring the loose
 comparison appears to be a safer option at this point.

 Should be fixed in [56138] :)

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/57839#comment:74>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list