diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-revisions-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-revisions-controller.php
index d3f665d..131e34c 100644
a
|
b
|
class WP_REST_Revisions_Controller extends WP_REST_Controller { |
338 | 338 | * @return WP_REST_Response Response object. |
339 | 339 | */ |
340 | 340 | public function prepare_item_for_response( $post, $request ) { |
| 341 | $GLOBALS['post'] = $post; |
| 342 | |
| 343 | setup_postdata( $post ); |
341 | 344 | |
342 | 345 | $schema = $this->get_item_schema(); |
343 | 346 | |
diff --git a/tests/phpunit/tests/rest-api/rest-revisions-controller.php b/tests/phpunit/tests/rest-api/rest-revisions-controller.php
index 4557004..cdb7e2b 100644
a
|
b
|
|
| 1 | |
1 | 2 | <?php |
2 | 3 | /** |
3 | 4 | * Unit tests covering WP_REST_Revisions_Controller functionality. |
… |
… |
class WP_Test_REST_Revisions_Controller extends WP_Test_REST_Controller_Testcase |
335 | 336 | $this->assertEquals( rest_url( '/wp/v2/' . $parent_base . '/' . $revision->post_parent ), $links['parent'][0]['href'] ); |
336 | 337 | } |
337 | 338 | |
| 339 | public function test_get_item_sets_up_postdata() { |
| 340 | wp_set_current_user( self::$editor_id ); |
| 341 | $request = new WP_REST_Request( 'GET', '/wp/v2/posts/' . self::$post_id . '/revisions/' . $this->revision_id1 ); |
| 342 | $this->server->dispatch( $request ); |
| 343 | |
| 344 | $post = get_post(); |
| 345 | $parent_post_id = wp_is_post_revision ( $post->ID ); |
| 346 | |
| 347 | $this->assertEquals( $post->ID, $this->revision_id1 ); |
| 348 | $this->assertEquals( $parent_post_id, self::$post_id ); |
| 349 | } |
| 350 | |
338 | 351 | } |