[wp-trac] [WordPress Trac] #43661: Un-neccessary call to get_post() in get_body_class() method
WordPress Trac
noreply at wordpress.org
Thu Mar 29 19:05:23 UTC 2018
#43661: Un-neccessary call to get_post() in get_body_class() method
------------------------------------+-----------------------------
Reporter: pat@… | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Formatting | Version: 4.9.4
Severity: normal | Keywords:
Focuses: multisite, performance |
------------------------------------+-----------------------------
I'm working with a multisite installation and selecting a Post from the
primary site to use as the queried_object on another blog when rendering
the front end.
When the body_class() method is called in my header template I've
encountered a problem with wp-includes/post-template starting on line 639:
639: } elseif ( is_page() ) {
642: $page_id = $wp_query->get_queried_object_id();
644: $post = get_post($page_id);
The queried object id and the post has already been defined on line 598
and 599:
$post_id = $wp_query->get_queried_object_id();
$post = $wp_query->get_queried_object();
With the call to get_post() it's invoking WP_Post::get_instance() which
can't return the Post I've already set as the queried object because it
doesn't exist on the current blog.
I'm aware it's a rare use case and there may be other issues I'll
encounter, but as far as I can tell the bit of code mentioned above is
redundant and can be removed.
Please?
--
Ticket URL: <https://core.trac.wordpress.org/ticket/43661>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list