Make WordPress Core

Opened 8 years ago

Last modified 7 years ago

#35913 new defect (bug)

`is_()` conditional methods should share their logic

Reported by: boonebgorges's profile boonebgorges Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version:
Component: Query Keywords: has-patch 2nd-opinion
Focuses: Cc:


Many of the is_() methods in WP_Query share the nearly the exact same logic. As such, they share the exact same bugs, and fixing those bugs requires many parallel changes and huge numbers of tests. See #35902 and #24674 for some recent examples.

It's possible to move all the shared logic to a single protected utility method. It's a bit more abstract, but is much easier to maintain and test.

Attachments (1)

35913.diff (6.6 KB) - added by boonebgorges 8 years ago.

Download all attachments as: .zip

Change History (3)

8 years ago

#1 @boonebgorges
8 years ago

35913.diff demonstrates how it can be done. (Look at all that red! <3)

The one slight functional change from the current behavior, made to simplify the new is_object_type(), is that *all* $object properties are cast to strings before the in_array() checks, instead of just the numerical ones. This will be redundant, since all of these properties are already strings.

Anyone have thoughts about the wisdom, or lack thereof, of this kind of abstraction?

#2 @swissspidy
7 years ago

I like the red!

Would be nice to see things move forward here.

Note: See TracTickets for help on using tickets.