WordPress.org

Make WordPress Core

Opened 21 months ago

Last modified 21 months ago

#38059 new defect (bug)

'wp_trim_excerpt' is not stripping oembed url's like shortcodes before applying 'the_content' filter

Reported by: wordpressdevhdn Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 4.5.3
Component: Formatting Keywords:
Focuses: performance Cc:

Description

The issue is performance related. We recently realized when more than 10 instagram urls are embedded into post directly via oEmbed urls, calling 'wp_trim_excerpt'(directly or indirectly via get_the_excerpt()) causes extreme slowness. If we wrap [embed]...embed shortcode around those urls, it does not cause any significant slowness. In context of function 'wp_trim_excerpt', both direct embeds and embedding with shortcode should result in same behavior and performance. So we should find way to strip shortcodes as well as any oEmbed urls before applying filter 'the_content'.

$text = get_the_content('');

$text = strip_shortcodes( $text );

/*We should strip any oEmbed urls here*/

/** This filter is documented in wp-includes/post-template.php */
$text = apply_filters( 'the_content', $text );

We're using version 4.5.3 but issue is also happening with latest development version. To reproduce the issue, enable jetpack plugin(in our case) or any other plugins that calls 'wp_trim_excerpt'(get_the_excerpt()), and add more than 20 instagram oEmbeds url(but can be mix of any other oEmbed urls) to the post. The post should take a while(>20 secs) to load in front end. The problem does not occur if we don't use Jetpack plugin or trigger wp_trim_excerpt function. Expected behavior should take same time to generate as if we used [embed]...embed which is about few seconds. Actual behavior is it takes too long to load post in front-end(>20 secs). It should happen in any environment since it's server side issue.

Change History (1)

#1 @swissspidy
21 months ago

  • Component changed from Embeds to Formatting
Note: See TracTickets for help on using tickets.