[wp-trac] [WordPress Trac] #35075: Comment cache ignores custom query vars
WordPress Trac
noreply at wordpress.org
Sun Jan 10 03:53:38 UTC 2016
#35075: Comment cache ignores custom query vars
-----------------------------+--------------------------
Reporter: jason_the_adams | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: 4.5
Component: Comments | Version: trunk
Severity: normal | Resolution:
Keywords: has-patch | Focuses: performance
-----------------------------+--------------------------
Comment (by nacin):
So, I'm almost positive that the reason for this code is that often these
arguments are passed through from higher level functions.
See [7738] for example. This is `get_terms()`. Now look at
`WP_Terms_List_Table`. The `$args` that go into `get_terms()` are actually
multi-purpose. The context can be generically explained in the following
example: `$args` is passed down the stack on purpose, so some template
function accepts `$args` which ends up being used directly in a lower-
level function to determine what to fetch, and then other `$args` (ignored
by the lower-level function) actually define templating.
In practice, this is not a terribly smart pattern, as it allows a future
API addition in the lower-level function to accidentally be stomped by a
well-intentioned higher-level function that already had that argument
name.
I'm struggling to find uses of this pattern, but I ''know'' it exists in
many places. I'll also claim (probably incorrectly) that I've never
implemented this pattern anywhere. I'll also claim (probably incorrectly)
that there are some good use cases for this, such as when we *want* to
automatically pick up API changes over time, since the higher-level
function is little more than a wrapper.
It's not "dependency injection", it's "argument injection"...
I am *sure* there is a practical reason why each of these calls were done
this way. It just might take a lot of spelunking to figure out why, to
ascertain what would break, and to determine how to avoid breaking it.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/35075#comment:18>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list