Ticket #42310: 42310.diff
File 42310.diff, 3.6 KB (added by , 7 years ago) |
---|
-
src/wp-admin/includes/ajax-actions.php
3034 3034 $parsed = false; 3035 3035 $wp_embed->return_false_on_fail = true; 3036 3036 3037 if ( 0 === $post_id ) { 3038 /* 3039 * Refresh oEmbeds cached outside of posts that are past their TTL. 3040 * Posts are excluded because they have separate logic for refreshing 3041 * their post meta caches. See WP_Embed::cache_oembed(). 3042 */ 3043 $wp_embed->usecache = false; 3044 } 3045 3037 3046 if ( is_ssl() && 0 === strpos( $url, 'http://' ) ) { 3038 3047 // Admin is ssl and the user pasted non-ssl URL. 3039 3048 // Check if the provider supports ssl embeds and use that for the preview. -
src/wp-includes/class-wp-embed.php
284 284 kses_remove_filters(); 285 285 } 286 286 287 wp_insert_post( wp_slash( array( 288 'post_name' => $key_suffix, 289 'post_content' => $html ? $html : '{{unknown}}', 290 'post_status' => 'publish', 291 'post_type' => 'oembed_cache', 292 ) ) ); 287 $insert_post_args = array( 288 'post_name' => $key_suffix, 289 'post_status' => 'publish', 290 'post_type' => 'oembed_cache', 291 ); 293 292 293 if ( $html ) { 294 if ( $cached_post_id ) { 295 wp_update_post( wp_slash( array( 296 'ID' => $cached_post_id, 297 'post_content' => $html, 298 ) ) ); 299 } else { 300 wp_insert_post( wp_slash( array_merge( 301 $insert_post_args, 302 array( 303 'post_content' => $html, 304 ) 305 ) ) ); 306 } 307 } elseif ( ! $cache ) { 308 wp_insert_post( wp_slash( array_merge( 309 $insert_post_args, 310 array( 311 'post_content' => '{{unknown}}', 312 ) 313 ) ) ); 314 } 315 294 316 if ( $has_kses ) { 295 317 kses_init_filters(); 296 318 } -
tests/phpunit/tests/oembed/WpEmbed.php
272 272 $this->assertEquals( '{{unknown}}', $post_content ); 273 273 } 274 274 275 public function test_shortcode_should_update_custom_post() { 276 add_filter( 'oembed_ttl', '__return_zero' ); 277 278 $url = 'https://example.com/'; 279 $embedded = '<b>Embedded content</b>'; 280 $key_suffix = md5( $url . serialize( wp_embed_defaults( $url ) ) ); 281 282 add_filter( 'pre_oembed_result', '__return_empty_string' ); 283 $this->wp_embed->shortcode( array(), $url ); 284 remove_filter( 'pre_oembed_result', '__return_empty_string' ); 285 286 $oembed_post_id = $this->wp_embed->find_oembed_post_id( $key_suffix ); 287 288 $this->assertSame( '{{unknown}}', get_post( $oembed_post_id )->post_content ); 289 290 $previous_usecache = $this->wp_embed->usecache; 291 $this->wp_embed->usecache = false; 292 293 // The update cannot be empty because empty responses won't overwrite the cache. 294 add_filter( 'pre_oembed_result', array( $this, '_pre_oembed_result_callback' ) ); 295 $this->wp_embed->shortcode( array(), $url ); 296 remove_filter( 'pre_oembed_result', array( $this, '_pre_oembed_result_callback' ) ); 297 298 $this->assertSame( $embedded, get_post( $oembed_post_id )->post_content ); 299 300 $this->wp_embed->usecache = $previous_usecache; 301 remove_filter( 'oembed_ttl', '__return_zero' ); 302 } 303 275 304 public function test_shortcode_should_get_url_from_src_attribute() { 276 305 $url = 'http://example.com/embed/foo'; 277 306 $actual = $this->wp_embed->shortcode( array( 'src' => $url ) );