Make WordPress Core

Opened 2 years ago

Last modified 2 years ago

#56489 new enhancement

An extra post lookup in WP_Embed::shortcode for known post

Reported by: davidbinda's profile david.binda Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Embeds Keywords:
Focuses: performance Cc:

Description

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, 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.

Attachments (3)

56489.diff (2.5 KB) - added by david.binda 2 years ago.
56489.2.diff (2.5 KB) - added by david.binda 2 years ago.
56489.3.diff (2.5 KB) - added by david.binda 2 years ago.

Download all attachments as: .zip

Change History (4)

@david.binda
2 years ago

@david.binda
2 years ago

@david.binda
2 years ago

#1 @david.binda
2 years ago

Sorry for attaching the same diff multiple times. There was a glitch in my internet connection and I have clicked the button multiple times :-)

Note: See TracTickets for help on using tickets.