Repository navigation
Conversation
Every case in the data provider passed a list of objects, and every case spelled the operator in uppercase. Two parts of `WP_List_Util::filter()` therefore never ran: * A list can hold arrays as well as objects, and the two are matched differently: arrays with `array_key_exists()`, objects with `isset()`. Only the object path was tested. * The operator is uppercased before it is checked against `AND`, `OR`, and `NOT`, so `and` works the same as `AND`. Since the tests only ever passed uppercase, dropping the `strtoupper()` would not have failed anything, even though `wp_filter_object_list()` itself defaults to lowercase `and`. Also adds cases for the default operator, an empty list, a `null` list, list values that are neither arrays nor objects, empty arguments with an invalid operator, string keys in the output, `OR` matching nothing, `NOT` matching everything, and a loose `true` to `'yes'` comparison alongside the existing numeric one. See #53987.
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
|
huzaifaalmesbah
left a comment
There was a problem hiding this comment.
Thanks for working on this, @mindctrl! I really appreciate the list of arrays cases and the lowercase operators, I checked them against WP_List_Util::filter() and they match, including the isset() and array_key_exists() difference for null. Looks good to me, I left one optional note inline.
AI Review: Opus 5.5
Every case in the data provider passed a list of objects, and every case spelled the operator in uppercase. Two parts of
WP_List_Util::filter()therefore never ran:array_key_exists(), objects withisset(). Only the object path was tested.AND,OR, andNOT, soandworks the same asAND. Since the tests only ever passed uppercase, dropping thestrtoupper()would not have failed anything, even thoughwp_filter_object_list()itself defaults to lowercaseand.Also adds cases for the default operator, an empty list, a
nulllist, list values that are neither arrays nor objects, empty arguments with an invalid operator, string keys in the output,ORmatching nothing,NOTmatching everything, and a loosetrueto'yes'comparison alongside the existing numeric one.See #53987.
Trac ticket: https://core.trac.wordpress.org/ticket/53987
Use of AI Tools
AI assistance: Yes
Tool(s): Claude
Model(s): Opus 5
Used for: Initial to identify gaps in testing and to generate tests for them