[wp-trac] [WordPress Trac] #56489: An extra post lookup in WP_Embed::shortcode for known post

WordPress Trac noreply at wordpress.org
Thu Sep 1 16:34:26 UTC 2022


#56489: An extra post lookup in WP_Embed::shortcode for known post
-------------------------+-----------------------------
 Reporter:  david.binda  |      Owner:  (none)
     Type:  enhancement  |     Status:  new
 Priority:  normal       |  Milestone:  Awaiting Review
Component:  Embeds       |    Version:
 Severity:  normal       |   Keywords:
  Focuses:  performance  |
-------------------------+-----------------------------
 `WP_Embed::shortcode` caches embeds into post_meta for known posts (ie.:
 embed in a post_content) or into a post of the `oembed_cache` post type in
 case the global post is not set (ie.: outside the loop).

 However, [https://core.trac.wordpress.org/browser/trunk/src/wp-includes
 /class-wp-embed.php?rev=53269#L251 the code] always tries to lookup the
 `oembed_cache` post, even in case the global post is set, which results in
 an extra SQL query, since the `oembed_cache` post is never created, if
 there is a known global post.

 The `$cached_post_id` variable populated by the
 `WP_Embed::find_oembed_post_id` function call is really only used in case
 there is no global post set, and thus, IMHO, should be only populated in
 such case.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/56489>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list