Changeset 41035
- Timestamp:
- 07/12/2017 10:50:57 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-oembed-controller.php
r40628 r41035 160 160 161 161 // Serve oEmbed data from cache if set. 162 unset( $args['_wpnonce'] ); 162 163 $cache_key = 'oembed_' . md5( serialize( $args ) ); 163 164 $data = get_transient( $cache_key ); -
trunk/tests/phpunit/tests/oembed/controller.php
r40628 r41035 11 11 protected $server; 12 12 protected static $editor; 13 protected static $administrator; 13 14 protected static $subscriber; 14 15 const YOUTUBE_VIDEO_ID = 'OQSNhk5ICTI'; … … 22 23 'role' => 'editor', 23 24 'user_email' => 'editor@example.com', 25 ) ); 26 self::$administrator = $factory->user->create( array( 27 'role' => 'administrator', 28 'user_email' => 'administrator@example.com', 24 29 ) ); 25 30 } … … 478 483 public function test_proxy_with_valid_oembed_provider() { 479 484 wp_set_current_user( self::$editor ); 480 481 485 $request = new WP_REST_Request( 'GET', '/oembed/1.0/proxy' ); 482 486 $request->set_param( 'url', 'https://www.youtube.com/watch?v=' . self::YOUTUBE_VIDEO_ID ); 487 $request->set_param( '_wpnonce', wp_create_nonce( 'wp_rest' ) ); 483 488 $response = $this->server->dispatch( $request ); 484 489 $this->assertEquals( 200, $response->get_status() ); … … 486 491 487 492 // Subsequent request is cached and so it should not cause a request. 493 $this->server->dispatch( $request ); 494 $this->assertEquals( 1, $this->request_count ); 495 496 // Rest with another user should also be cached. 497 wp_set_current_user( self::$administrator ); 498 $request = new WP_REST_Request( 'GET', '/oembed/1.0/proxy' ); 499 $request->set_param( 'url', 'https://www.youtube.com/watch?v=' . self::YOUTUBE_VIDEO_ID ); 500 $request->set_param( '_wpnonce', wp_create_nonce( 'wp_rest' ) ); 488 501 $response = $this->server->dispatch( $request ); 489 502 $this->assertEquals( 1, $this->request_count );
Note: See TracChangeset
for help on using the changeset viewer.