[wp-trac] [WordPress Trac] #53988: remove duplicate code in wp_list_filter()

WordPress Trac noreply at wordpress.org
Tue Aug 24 15:51:47 UTC 2021


#53988: remove duplicate code in wp_list_filter()
-------------------------+---------------------
 Reporter:  pbearne      |       Owner:  (none)
     Type:  enhancement  |      Status:  new
 Priority:  normal       |   Milestone:  5.9
Component:  General      |     Version:
 Severity:  normal       |  Resolution:
 Keywords:  has-patch    |     Focuses:
-------------------------+---------------------

Comment (by SergeyBiryukov):

 The failure is because `WP_List_Util::filter()` performs validation of the
 `$operator` argument, but in case of an invalid operator it just returns
 early and does not assign the `$this->output` value that
 `wp_filter_object_list()` returns.

 This means that `wp_filter_object_list()` and `wp_list_filter()` treat an
 invalid operator differently:
 * `wp_filter_object_list()` returns the original array.
 * `wp_list_filter()` returns an empty array.

 [attachment:53988.diff] fixes that and the tests
 [https://github.com/SergeyBiryukov/wordpress-
 develop/runs/3412882523?check_suite_focus=true seem to pass now], though
 it might be up for discussion whether the current behavior is a bug or a
 feature.

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


More information about the wp-trac mailing list