diff --git a/wp-admin/includes/ajax-actions.php b/wp-admin/includes/ajax-actions.php index 43f59b66ec..5985e3561a 100644 --- a/wp-admin/includes/ajax-actions.php +++ b/wp-admin/includes/ajax-actions.php @@ -3027,6 +3027,15 @@ function wp_ajax_parse_embed() { $parsed = false; $wp_embed->return_false_on_fail = true; + if ( 0 === $post_id ) { + /* + * Refresh oEmbeds cached outside of posts that are past their TTL. + * Posts are excluded because they have separate logic for refreshing + * their post meta caches. See WP_Embed::cache_oembed(). + */ + $wp_embed->usecache = false; + } + if ( is_ssl() && 0 === strpos( $url, 'http://' ) ) { // Admin is ssl and the user pasted non-ssl URL. // Check if the provider supports ssl embeds and use that for the preview. diff --git a/wp-includes/class-wp-embed.php b/wp-includes/class-wp-embed.php index c40ae2db59..4674caeb9f 100644 --- a/wp-includes/class-wp-embed.php +++ b/wp-includes/class-wp-embed.php @@ -284,12 +284,34 @@ class WP_Embed { kses_remove_filters(); } - wp_insert_post( wp_slash( array( - 'post_name' => $key_suffix, - 'post_content' => $html ? $html : '{{unknown}}', - 'post_status' => 'publish', - 'post_type' => 'oembed_cache', - ) ) ); + $insert_post_args = array( + 'post_name' => $key_suffix, + 'post_status' => 'publish', + 'post_type' => 'oembed_cache', + ); + + if ( $html ) { + if ( $cached_post_id ) { + wp_update_post( wp_slash( array( + 'ID' => $cached_post_id, + 'post_content' => $html, + ) ) ); + } else { + wp_insert_post( wp_slash( array_merge( + $insert_post_args, + array( + 'post_content' => $html, + ) + ) ) ); + } + } elseif ( ! $cache ) { + wp_insert_post( wp_slash( array_merge( + $insert_post_args, + array( + 'post_content' => '{{unknown}}', + ) + ) ) ); + } if ( $has_kses ) { kses_init_filters(); diff --git a/wp-includes/version.php b/wp-includes/version.php index e9a0df0663..74712b4389 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.9-beta3-42008'; +$wp_version = '4.9-beta3-42009'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.