[wp-trac] [WordPress Trac] #43661: Un-neccessary call to get_post() in get_body_class() method

WordPress Trac noreply at wordpress.org
Tue Aug 22 12:31:01 UTC 2023


#43661: Un-neccessary call to get_post() in get_body_class() method
-------------------------------------+-------------------------------------
 Reporter:  pat@…                    |       Owner:  spacedmonkey
     Type:  enhancement              |      Status:  closed
 Priority:  normal                   |   Milestone:  6.4
Component:  Posts, Post Types        |     Version:  4.9.4
 Severity:  normal                   |  Resolution:  fixed
 Keywords:  has-patch needs-testing  |     Focuses:  multisite, performance
-------------------------------------+-------------------------------------
Changes (by SergeyBiryukov):

 * status:  assigned => closed
 * resolution:   => fixed


Comment:

 In [changeset:"56424" 56424]:
 {{{
 #!CommitTicketReference repository="" revision="56424"
 Posts, Post Types: Remove redundant function calls in `get_body_class()`.

 As part of a previous change to add support for post type templates, the
 `$wp_query->get_queried_object_id()` method ended up being called twice,
 in both the `is_singular()` and `is_page()` conditional branches.

 The `get_post()` function call was also unnecessary, as
 `$wp_query->get_queried_object()` is already called in the `is_singular()`
 branch above, which includes the `is_page()` branch too.

 This commit removes the redundant calls. The first
 `$wp_query->get_queried_object_id()` call is removed as well, since the
 post ID is already available via `$wp_query->get_queried_object()`.

 Follow-up to [10485], [10877], [12877], [13032], [21597], [38951].

 Props mattkeys, spacedmonkey, oglekler.
 Fixes #43661.
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/43661#comment:6>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list