[wp-trac] [WordPress Trac] #20177: Unneccessary term cache query for pages
WordPress Trac
wp-trac at lists.automattic.com
Mon Mar 5 12:02:41 UTC 2012
#20177: Unneccessary term cache query for pages
--------------------------+-----------------------------
Reporter: TheDeadMedic | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Query | Version:
Severity: normal | Keywords:
--------------------------+-----------------------------
When a request for a page is queried, {{{$post_type}}} in
{{{WP_Query::get_posts()}}} is an empty string, which is then passed to
{{{update_post_caches()}}}.
This in turn calls {{{update_object_term_cache()}}} for 'post' (the
default if {{{$post_type}}} is empty) instead of 'page'.
Since pages don't have taxonomies (at least not in a default setup), we're
simply wasting a query. But even if they ''did'' have, we wouldn't even be
caching the right ones (unless of course pages were assigned the same
taxes as posts).
I would say there's two options here; review {{{WP_Query::get_posts()}}}
to ensure the local variable {{{$post_type}}} is set correctly, or simply
pass the string {{{any}}} to {{{update_post_caches()}}} (which will then
correctly determine the post type(s)) - thoughts?
--
Ticket URL: <http://core.trac.wordpress.org/ticket/20177>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list