From 69d81f3129af11f6fb8cdee1c8007628d3e2bbc8 Mon Sep 17 00:00:00 2001 From: Sukhendu Sekhar Guria Date: Tue, 23 Jun 2026 13:33:47 +0530 Subject: [PATCH 1/6] Revisions: Save initial revision for inserted posts --- src/wp-includes/revision.php | 37 ++- src/wp-includes/theme.php | 12 +- tests/phpunit/tests/post/revisions.php | 256 +++++++++++++++--- .../rest-api/rest-revisions-controller.php | 27 +- .../phpunit/tests/xmlrpc/wp/getRevisions.php | 4 +- 5 files changed, 256 insertions(+), 80 deletions(-) diff --git a/src/wp-includes/revision.php b/src/wp-includes/revision.php index 11f2bba9d97ff..2a1b014467a44 100644 --- a/src/wp-includes/revision.php +++ b/src/wp-includes/revision.php @@ -100,20 +100,22 @@ function _wp_post_revision_data( $post = array(), $autosave = false ) { * * @since 6.4.0 * - * @param int $post_id The post id that was inserted. - * @param WP_Post $post The post object that was inserted. + * @param int $post_id The post ID that was inserted or updated. + * @param WP_Post $post The post object that was inserted or updated. * @param bool $update Whether this insert is updating an existing post. */ function wp_save_post_revision_on_insert( $post_id, $post, $update ) { - if ( ! $update ) { + if ( ! has_action( 'post_updated', 'wp_save_post_revision' ) ) { return; } - if ( ! has_action( 'post_updated', 'wp_save_post_revision' ) ) { - return; + $revision_author = null; + + if ( ! $update && 0 === get_current_user_id() ) { + $revision_author = $post->post_author; } - wp_save_post_revision( $post_id ); + wp_save_post_revision( $post_id, $revision_author ); } /** @@ -123,11 +125,13 @@ function wp_save_post_revision_on_insert( $post_id, $post, $update ) { * and the most recent revision always matches the current post. * * @since 2.6.0 + * @since 7.1.0 The `$revision_author` parameter was added. * - * @param int $post_id The ID of the post to save as a revision. + * @param int $post_id The ID of the post to save as a revision. + * @param int|null $revision_author Optional. The revision author ID. Default null. * @return int|WP_Error|null Null or 0 if error, new revision ID, if success. */ -function wp_save_post_revision( $post_id ) { +function wp_save_post_revision( $post_id, $revision_author = null ) { if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { return null; } @@ -214,7 +218,7 @@ function wp_save_post_revision( $post_id ) { } } - $return = _wp_put_post_revision( $post ); + $return = _wp_put_post_revision( $post, false, $revision_author ); /* * If a limit for the number of revisions to keep has been set, @@ -344,14 +348,16 @@ function wp_is_post_autosave( $post ) { * Inserts post data into the posts table as a post revision. * * @since 2.6.0 + * @since 7.1.0 The `$post_author` parameter was added. * @access private * - * @param int|WP_Post|array|null $post Post ID, post object OR post array. - * @param bool $autosave Optional. Whether the revision is an autosave or not. - * Default false. + * @param int|WP_Post|array|null $post Post ID, post object OR post array. + * @param bool $autosave Optional. Whether the revision is an autosave or not. + * Default false. + * @param int|null $post_author Optional. The revision author ID. Default null. * @return int|WP_Error WP_Error or 0 if error, new revision ID if success. */ -function _wp_put_post_revision( $post = null, $autosave = false ) { +function _wp_put_post_revision( $post = null, $autosave = false, $post_author = null ) { if ( is_object( $post ) ) { $post = get_object_vars( $post ); } elseif ( ! is_array( $post ) ) { @@ -367,6 +373,11 @@ function _wp_put_post_revision( $post = null, $autosave = false ) { } $post = _wp_post_revision_data( $post, $autosave ); + + if ( null !== $post_author ) { + $post['post_author'] = absint( $post_author ); + } + $post = wp_slash( $post ); // Since data is from DB. $revision_id = wp_insert_post( $post, true ); diff --git a/src/wp-includes/theme.php b/src/wp-includes/theme.php index 07869ae61d0ff..222af49a68161 100644 --- a/src/wp-includes/theme.php +++ b/src/wp-includes/theme.php @@ -2141,16 +2141,8 @@ function wp_update_custom_css_post( $css, $args = array() ) { } else { $r = wp_insert_post( wp_slash( $post_data ), true ); - if ( ! is_wp_error( $r ) ) { - if ( get_stylesheet() === $args['stylesheet'] ) { - set_theme_mod( 'custom_css_post_id', $r ); - } - - // Trigger creation of a revision. This should be removed once #30854 is resolved. - $revisions = wp_get_latest_revision_id_and_total_count( $r ); - if ( ! is_wp_error( $revisions ) && 0 === $revisions['count'] ) { - wp_save_post_revision( $r ); - } + if ( ! is_wp_error( $r ) && get_stylesheet() === $args['stylesheet'] ) { + set_theme_mod( 'custom_css_post_id', $r ); } } diff --git a/tests/phpunit/tests/post/revisions.php b/tests/phpunit/tests/post/revisions.php index 5b6e70b4605bf..66a23ebfca151 100644 --- a/tests/phpunit/tests/post/revisions.php +++ b/tests/phpunit/tests/post/revisions.php @@ -227,7 +227,7 @@ public function test_revision_view_caps_post() { ); $revisions = wp_get_post_revisions( $post_id ); - $this->assertCount( 1, $revisions ); + $this->assertCount( 2, $revisions ); $this->assertTrue( user_can( self::$editor_user_id, 'read_post', $post_id ) ); $this->assertNotEmpty( $revisions ); @@ -262,7 +262,7 @@ public function test_revision_restore_caps_post() { ); $revisions = wp_get_post_revisions( $post_id ); - $this->assertCount( 1, $revisions ); + $this->assertCount( 2, $revisions ); foreach ( $revisions as $revision ) { $this->assertTrue( user_can( self::$editor_user_id, 'edit_post', $revision->post_parent ) ); } @@ -300,7 +300,7 @@ public function test_revision_diff_caps_post() { // Diff checks if you can read both left and right revisions. $revisions = wp_get_post_revisions( $post_id ); - $this->assertCount( 2, $revisions ); + $this->assertCount( 3, $revisions ); foreach ( $revisions as $revision ) { $this->assertTrue( user_can( self::$editor_user_id, 'read_post', $revision->ID ) ); } @@ -340,7 +340,7 @@ public function test_revision_view_caps_cpt() { ); $revisions = wp_get_post_revisions( $post_id ); - $this->assertCount( 1, $revisions ); + $this->assertCount( 2, $revisions ); $this->assertTrue( user_can( self::$editor_user_id, 'read_post', $post_id ) ); foreach ( $revisions as $revision ) { @@ -387,7 +387,7 @@ public function test_revision_restore_caps_cpt() { ); $revisions = wp_get_post_revisions( $post_id ); - $this->assertCount( 1, $revisions ); + $this->assertCount( 2, $revisions ); foreach ( $revisions as $revision ) { $this->assertTrue( user_can( self::$editor_user_id, 'edit_post', $revision->post_parent ) ); } @@ -436,7 +436,7 @@ public function test_revision_restore_caps_before_publish() { ); $revisions = wp_get_post_revisions( $post_id ); - $this->assertCount( 1, $revisions ); + $this->assertCount( 2, $revisions ); foreach ( $revisions as $revision ) { $this->assertTrue( current_user_can( 'edit_post', $revision->post_parent ) ); $this->assertTrue( current_user_can( 'edit_post', $revision->ID ) ); @@ -451,7 +451,7 @@ public function test_revision_restore_caps_before_publish() { ); $revisions = wp_get_post_revisions( $post_id ); - $this->assertCount( 2, $revisions ); + $this->assertCount( 3, $revisions ); foreach ( $revisions as $revision ) { $this->assertFalse( current_user_can( 'edit_post', $revision->post_parent ) ); $this->assertFalse( current_user_can( 'edit_post', $revision->ID ) ); @@ -495,7 +495,7 @@ public function test_revision_diff_caps_cpt() { // Diff checks if you can read both left and right revisions. $revisions = wp_get_post_revisions( $post_id ); - $this->assertCount( 2, $revisions ); + $this->assertCount( 3, $revisions ); foreach ( $revisions as $revision ) { $this->assertTrue( user_can( self::$editor_user_id, 'read_post', $revision->ID ) ); } @@ -539,6 +539,8 @@ public function test_wp_get_post_revisions_should_order_by_post_date() { $revisions = wp_get_post_revisions( $post['ID'] ); + array_unshift( $revision_ids, reset( $revisions )->ID ); + $this->assertSame( $revision_ids, array_values( wp_list_pluck( $revisions, 'ID' ) ) ); } @@ -574,6 +576,8 @@ public function test_wp_get_post_revisions_should_order_by_ID_when_post_date_mat $revisions = wp_get_post_revisions( $post['ID'] ); + array_unshift( $revision_ids, reset( $revisions )->ID ); + $this->assertSame( $revision_ids, array_values( wp_list_pluck( $revisions, 'ID' ) ) ); } @@ -655,6 +659,170 @@ public function test_wp_save_post_revision_error() { $this->assertWPError( $revision ); } + /** + * Tests that wp_insert_post() saves the initial revision. + * + * @ticket 30854 + */ + public function test_wp_insert_post_saves_initial_revision() { + $post_id = self::factory()->post->create( + array( + 'post_title' => 'Initial title', + 'post_content' => 'Initial content', + 'post_excerpt' => 'Initial excerpt', + 'post_status' => 'publish', + ) + ); + + $revisions = wp_get_post_revisions( $post_id ); + + $this->assertCount( 1, $revisions, 'Initial revision should be created.' ); + $this->assertContains( + 'Initial content', + wp_list_pluck( $revisions, 'post_content' ), + 'Initial revision should preserve the inserted content.' + ); + + wp_update_post( + array( + 'ID' => $post_id, + 'post_content' => 'Updated content', + ) + ); + + $revisions = wp_get_post_revisions( $post_id ); + + $this->assertCount( 2, $revisions, 'Update should create a second revision.' ); + $this->assertContains( + 'Initial content', + wp_list_pluck( $revisions, 'post_content' ), + 'First revision should not be lost after an update.' + ); + } + + /** + * Tests that wp_insert_post() saves the initial revision for custom post statuses. + * + * @ticket 30854 + */ + public function test_wp_insert_post_saves_initial_revision_for_custom_post_status() { + global $wp_post_statuses; + + register_post_status( 'test-revision-status' ); + + try { + $post_id = self::factory()->post->create( + array( + 'post_title' => 'Initial title', + 'post_content' => 'Initial content', + 'post_status' => 'test-revision-status', + ) + ); + } finally { + unset( $wp_post_statuses['test-revision-status'] ); + } + + $revisions = wp_get_post_revisions( $post_id ); + + $this->assertCount( 1, $revisions, 'Initial revision should be created.' ); + $this->assertContains( + 'Initial content', + wp_list_pluck( $revisions, 'post_content' ), + 'Initial revision should preserve the inserted content.' + ); + } + + /** + * Tests the author for initial revisions. + * + * @ticket 30854 + */ + public function test_wp_insert_post_saves_initial_revision_author() { + $old_user_id = get_current_user_id(); + + wp_set_current_user( 0 ); + $no_current_user_post_id = self::factory()->post->create( + array( + 'post_author' => self::$author_user_id, + 'post_title' => 'Initial title', + 'post_content' => 'Initial content', + 'post_status' => 'publish', + ) + ); + $no_current_user_revisions = wp_get_post_revisions( $no_current_user_post_id ); + $no_current_user_revision = reset( $no_current_user_revisions ); + + wp_set_current_user( self::$admin_user_id ); + $current_user_post_id = self::factory()->post->create( + array( + 'post_author' => self::$author_user_id, + 'post_title' => 'Initial title', + 'post_content' => 'Initial content', + 'post_status' => 'publish', + ) + ); + $current_user_revisions = wp_get_post_revisions( $current_user_post_id ); + $current_user_revision = reset( $current_user_revisions ); + + wp_set_current_user( $old_user_id ); + + $this->assertSame( + self::$author_user_id, + (int) $no_current_user_revision->post_author, + 'Initial revision author should match the post author when there is no current user.' + ); + $this->assertSame( + self::$admin_user_id, + (int) $current_user_revision->post_author, + 'Initial revision author should match the current user.' + ); + } + + /** + * Tests that wp_insert_post() does not save initial revisions when revisions should not be saved. + * + * @ticket 30854 + */ + public function test_wp_insert_post_does_not_save_initial_revision_when_revisions_should_not_be_saved() { + $auto_draft_post_id = self::factory()->post->create( + array( + 'post_title' => 'Auto draft title', + 'post_content' => 'Auto draft content', + 'post_status' => 'auto-draft', + ) + ); + + remove_post_type_support( 'post', 'revisions' ); + try { + $unsupported_post_id = self::factory()->post->create( + array( + 'post_title' => 'No revision title', + 'post_content' => 'No revision content', + 'post_status' => 'publish', + ) + ); + } finally { + add_post_type_support( 'post', 'revisions' ); + } + + remove_action( 'post_updated', 'wp_save_post_revision', 10 ); + try { + $action_removed_post_id = self::factory()->post->create( + array( + 'post_title' => 'No revision title', + 'post_content' => 'No revision content', + 'post_status' => 'publish', + ) + ); + } finally { + add_action( 'post_updated', 'wp_save_post_revision', 10, 1 ); + } + + $this->assertCount( 0, wp_get_post_revisions( $auto_draft_post_id ), 'Auto-drafts should not save initial revisions.' ); + $this->assertCount( 0, wp_get_post_revisions( $unsupported_post_id ), 'Post types without revision support should not save initial revisions.' ); + $this->assertCount( 0, wp_get_post_revisions( $action_removed_post_id ), 'Removing the default revision action should disable initial revisions.' ); + } + /** * Tests that wp_get_latest_revision_id_and_total_count() returns the latest revision ID and total count. * @@ -724,25 +892,20 @@ public function test_wp_get_latest_revision_id_and_total_count_no_revisions() { public function test_wp_get_post_revisions_url( $revisions ) { wp_set_current_user( self::$admin_user_id ); - $post_id = self::factory()->post->create( array( 'post_title' => 'Some Post' ) ); - $latest_revision_id = null; - - if ( 0 !== $revisions ) { - $latest_revision_id = $post_id; - - for ( $i = 0; $i < $revisions; ++$i ) { - wp_update_post( - array( - 'ID' => $post_id, - 'post_title' => 'Some Post ' . $i, - ) - ); + $post_id = self::factory()->post->create( array( 'post_title' => 'Some Post' ) ); - ++$latest_revision_id; - } + for ( $i = 0; $i < $revisions; ++$i ) { + wp_update_post( + array( + 'ID' => $post_id, + 'post_title' => 'Some Post ' . $i, + ) + ); } - $expected = admin_url( 'revision.php?revision=' . $latest_revision_id ); + $post_revisions = wp_get_post_revisions( $post_id ); + $latest_revision = reset( $post_revisions ); + $expected = admin_url( 'revision.php?revision=' . $latest_revision->ID ); $this->assertSame( $expected, @@ -752,7 +915,7 @@ public function test_wp_get_post_revisions_url( $revisions ) { $this->assertSame( $expected, - wp_get_post_revisions_url( $latest_revision_id ), + wp_get_post_revisions_url( $latest_revision->ID ), 'Failed when passed the latest revision ID' ); } @@ -772,25 +935,20 @@ public function test_wp_get_post_revisions_url( $revisions ) { public function test_wp_get_post_revisions_url_with_post_object( $revisions ) { wp_set_current_user( self::$admin_user_id ); - $post = self::factory()->post->create_and_get( array( 'post_title' => 'Some Post' ) ); - $latest_revision_id = null; - - if ( 0 !== $revisions ) { - $latest_revision_id = $post->ID; - - for ( $i = 0; $i < $revisions; ++$i ) { - wp_update_post( - array( - 'ID' => $post->ID, - 'post_title' => 'Some Post ' . $i, - ) - ); + $post = self::factory()->post->create_and_get( array( 'post_title' => 'Some Post' ) ); - ++$latest_revision_id; - } + for ( $i = 0; $i < $revisions; ++$i ) { + wp_update_post( + array( + 'ID' => $post->ID, + 'post_title' => 'Some Post ' . $i, + ) + ); } - $expected = admin_url( 'revision.php?revision=' . $latest_revision_id ); + $post_revisions = wp_get_post_revisions( $post->ID ); + $latest_revision = reset( $post_revisions ); + $expected = admin_url( 'revision.php?revision=' . $latest_revision->ID ); $this->assertSame( $expected, @@ -800,7 +958,7 @@ public function test_wp_get_post_revisions_url_with_post_object( $revisions ) { $this->assertSame( $expected, - wp_get_post_revisions_url( $latest_revision_id ), + wp_get_post_revisions_url( $latest_revision->ID ), 'Failed when passed the latest revision ID' ); } @@ -839,7 +997,12 @@ public function test_wp_get_post_revisions_url_returns_null_when_post_does_not_e */ public function test_wp_get_post_revisions_url_returns_null_with_no_revisions() { wp_set_current_user( self::$admin_user_id ); - $post_id = self::factory()->post->create( array( 'post_title' => 'Some Post' ) ); + $post_id = self::factory()->post->create( + array( + 'post_title' => 'Some Post', + 'post_status' => 'auto-draft', + ) + ); $this->assertNull( wp_get_post_revisions_url( $post_id ) ); } @@ -925,7 +1088,7 @@ static function ( $revisions ) { ); $this->assertSame( - 'Test 57320 Update 1', + 'Test 57320', $second->post_title, 'The title of the second revision was incorrect.' ); @@ -939,7 +1102,10 @@ public function test_wp_save_post_revision_with_array_post_meta() { // This filter is true by default, but this is explicitly to test looking for differences among non-scalar fields. add_filter( 'wp_save_post_revision_check_for_changes', '__return_true' ); - $post_id = self::factory()->post->create(); + remove_action( 'wp_after_insert_post', 'wp_save_post_revision_on_insert', 9 ); + $post_id = self::factory()->post->create(); + add_action( 'wp_after_insert_post', 'wp_save_post_revision_on_insert', 9, 3 ); + $meta_key = 'favorite_things'; // Ensure the post meta is saved with each revision. diff --git a/tests/phpunit/tests/rest-api/rest-revisions-controller.php b/tests/phpunit/tests/rest-api/rest-revisions-controller.php index 52011afcb9318..128e9e2a41954 100644 --- a/tests/phpunit/tests/rest-api/rest-revisions-controller.php +++ b/tests/phpunit/tests/rest-api/rest-revisions-controller.php @@ -23,6 +23,8 @@ class WP_Test_REST_Revisions_Controller extends WP_Test_REST_Controller_Testcase private $revision_id2; private $revision_3; private $revision_id3; + private $revision_initial; + private $revision_initial_id; private $revision_2_1_id; public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) { @@ -89,15 +91,17 @@ public function set_up() { parent::set_up(); // Set first post revision vars. - $revisions = wp_get_post_revisions( self::$post_id ); - $this->total_revisions = count( $revisions ); - $this->revisions = $revisions; - $this->revision_1 = array_pop( $revisions ); - $this->revision_id1 = $this->revision_1->ID; - $this->revision_2 = array_pop( $revisions ); - $this->revision_id2 = $this->revision_2->ID; - $this->revision_3 = array_pop( $revisions ); - $this->revision_id3 = $this->revision_3->ID; + $revisions = array_values( wp_get_post_revisions( self::$post_id ) ); + $this->total_revisions = count( $revisions ); + $this->revisions = $revisions; + $this->revision_3 = $revisions[0]; + $this->revision_id3 = $this->revision_3->ID; + $this->revision_2 = $revisions[1]; + $this->revision_id2 = $this->revision_2->ID; + $this->revision_1 = $revisions[2]; + $this->revision_id1 = $this->revision_1->ID; + $this->revision_initial = $revisions[3]; + $this->revision_initial_id = $this->revision_initial->ID; // Set second post revision vars. $revisions = wp_get_post_revisions( self::$post_id_2 ); @@ -160,6 +164,9 @@ public function test_get_items() { $this->assertSame( $this->revision_id1, $data[2]['id'] ); $this->check_get_revision_response( $data[2], $this->revision_1 ); + + $this->assertSame( $this->revision_initial_id, $data[3]['id'] ); + $this->check_get_revision_response( $data[3], $this->revision_initial ); } /** @@ -1070,7 +1077,7 @@ public function test_get_revisions_pagination() { $response = rest_get_server()->dispatch( $request ); $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); - $this->assertCount( 1, $data ); + $this->assertCount( 2, $data ); $this->assertSame( $this->total_revisions, $response->get_headers()['X-WP-Total'] ); $this->assertSame( (int) ceil( $this->total_revisions / 2 ), $response->get_headers()['X-WP-TotalPages'] ); diff --git a/tests/phpunit/tests/xmlrpc/wp/getRevisions.php b/tests/phpunit/tests/xmlrpc/wp/getRevisions.php index 893a7a06dae93..43cf1459f1fa5 100644 --- a/tests/phpunit/tests/xmlrpc/wp/getRevisions.php +++ b/tests/phpunit/tests/xmlrpc/wp/getRevisions.php @@ -42,7 +42,7 @@ public function test_revision_count() { $result = $this->myxmlrpcserver->wp_getRevisions( array( 1, 'editor', 'editor', $post_id ) ); $this->assertIsArray( $result ); - $this->assertCount( 1, $result ); + $this->assertCount( 2, $result ); wp_insert_post( array( @@ -53,7 +53,7 @@ public function test_revision_count() { $result = $this->myxmlrpcserver->wp_getRevisions( array( 1, 'editor', 'editor', $post_id ) ); $this->assertIsArray( $result ); - $this->assertCount( 2, $result ); + $this->assertCount( 3, $result ); } /** From 7736afa0a9aa363c5db05086e3de6fd28ab509b0 Mon Sep 17 00:00:00 2001 From: Sukhendu Sekhar Guria Date: Tue, 23 Jun 2026 14:35:30 +0530 Subject: [PATCH 2/6] refactor: simplify revision insert and tighten initial-revision tests --- src/wp-includes/revision.php | 11 ++-- tests/phpunit/tests/post/metaRevisions.php | 18 ++--- tests/phpunit/tests/post/revisions.php | 21 ------ tests/phpunit/tests/post/wpDeletePost.php | 8 ++- ...est-global-styles-revisions-controller.php | 22 +++---- .../tests/rest-api/rest-posts-controller.php | 17 +++-- .../wpRestTemplateRevisionsController.php | 65 ++++++------------- 7 files changed, 62 insertions(+), 100 deletions(-) diff --git a/src/wp-includes/revision.php b/src/wp-includes/revision.php index 2a1b014467a44..8c49c6e98dc52 100644 --- a/src/wp-includes/revision.php +++ b/src/wp-includes/revision.php @@ -109,13 +109,10 @@ function wp_save_post_revision_on_insert( $post_id, $post, $update ) { return; } - $revision_author = null; - - if ( ! $update && 0 === get_current_user_id() ) { - $revision_author = $post->post_author; - } - - wp_save_post_revision( $post_id, $revision_author ); + wp_save_post_revision( + $post_id, + ! $update && 0 === get_current_user_id() ? $post->post_author : null + ); } /** diff --git a/tests/phpunit/tests/post/metaRevisions.php b/tests/phpunit/tests/post/metaRevisions.php index a95cc3a260a26..e6a881cd9ff6a 100644 --- a/tests/phpunit/tests/post/metaRevisions.php +++ b/tests/phpunit/tests/post/metaRevisions.php @@ -39,7 +39,7 @@ public function test_revisions_stores_meta_values_with_slashes( $passed, $expect // Set up a new post. $post_id = $this->factory->post->create(); - // And update to store an initial revision. + // And update to store another revision. wp_update_post( array( 'post_content' => 'some initial content', @@ -121,7 +121,7 @@ public function test_revisions_stores_meta_values() { $post_id = $this->factory->post->create(); $original_post_id = $post_id; - // And update to store an initial revision. + // And update to store another revision. wp_update_post( array( 'post_content' => 'some initial content', @@ -129,9 +129,9 @@ public function test_revisions_stores_meta_values() { ) ); - // One revision so far. + // Two revisions so far, including the initial revision. $revisions = wp_get_post_revisions( $post_id ); - $this->assertCount( 1, $revisions ); + $this->assertCount( 2, $revisions ); /* * First set up a meta value. @@ -149,7 +149,7 @@ public function test_revisions_stores_meta_values() { ); $revisions = wp_get_post_revisions( $post_id ); - $this->assertCount( 2, $revisions ); + $this->assertCount( 3, $revisions ); // Next, store some updated meta values for the same key. update_post_meta( $post_id, 'meta_revision_test', 'update1' ); @@ -163,7 +163,7 @@ public function test_revisions_stores_meta_values() { ); $revisions = wp_get_post_revisions( $post_id ); - $this->assertCount( 3, $revisions ); + $this->assertCount( 4, $revisions ); /* * Now restore the original revision. @@ -181,7 +181,7 @@ public function test_revisions_stores_meta_values() { wp_update_post( array( 'ID' => $post_id ) ); $revisions = wp_get_post_revisions( $post_id ); - $this->assertCount( 4, $revisions ); + $this->assertCount( 5, $revisions ); /* * Check the meta values to verify they are NOT revisioned - they are not revisioned by default. @@ -208,7 +208,7 @@ public function test_revisions_stores_meta_values() { ); $revisions = array_values( wp_get_post_revisions( $post_id ) ); - $this->assertCount( 5, $revisions ); + $this->assertCount( 6, $revisions ); $this->assertSame( 'update2', get_post_meta( $revisions[0]->ID, 'meta_revision_test', true ) ); // Store custom meta values, which should now be revisioned. @@ -228,7 +228,7 @@ public function test_revisions_stores_meta_values() { // This revision contains the existing post meta ('update3'). $revisions = wp_get_post_revisions( $post_id ); - $this->assertCount( 6, $revisions ); + $this->assertCount( 7, $revisions ); // Verify that previous post meta is set. $this->assertSame( 'update3', get_post_meta( $post_id, 'meta_revision_test', true ) ); diff --git a/tests/phpunit/tests/post/revisions.php b/tests/phpunit/tests/post/revisions.php index 66a23ebfca151..86ec7520b4242 100644 --- a/tests/phpunit/tests/post/revisions.php +++ b/tests/phpunit/tests/post/revisions.php @@ -682,22 +682,6 @@ public function test_wp_insert_post_saves_initial_revision() { wp_list_pluck( $revisions, 'post_content' ), 'Initial revision should preserve the inserted content.' ); - - wp_update_post( - array( - 'ID' => $post_id, - 'post_content' => 'Updated content', - ) - ); - - $revisions = wp_get_post_revisions( $post_id ); - - $this->assertCount( 2, $revisions, 'Update should create a second revision.' ); - $this->assertContains( - 'Initial content', - wp_list_pluck( $revisions, 'post_content' ), - 'First revision should not be lost after an update.' - ); } /** @@ -725,11 +709,6 @@ public function test_wp_insert_post_saves_initial_revision_for_custom_post_statu $revisions = wp_get_post_revisions( $post_id ); $this->assertCount( 1, $revisions, 'Initial revision should be created.' ); - $this->assertContains( - 'Initial content', - wp_list_pluck( $revisions, 'post_content' ), - 'Initial revision should preserve the inserted content.' - ); } /** diff --git a/tests/phpunit/tests/post/wpDeletePost.php b/tests/phpunit/tests/post/wpDeletePost.php index 5382e496b7049..1b8e29f003d3d 100644 --- a/tests/phpunit/tests/post/wpDeletePost.php +++ b/tests/phpunit/tests/post/wpDeletePost.php @@ -159,7 +159,13 @@ static function () use ( $action, &$captured_action_args ) { ); } - $post_id = self::factory()->post->create(); + remove_post_type_support( 'post', 'revisions' ); + try { + $post_id = self::factory()->post->create(); + } finally { + add_post_type_support( 'post', 'revisions' ); + } + $deleted_post = wp_delete_post( (string) $post_id, true ); $this->assertInstanceOf( WP_Post::class, $deleted_post ); diff --git a/tests/phpunit/tests/rest-api/rest-global-styles-revisions-controller.php b/tests/phpunit/tests/rest-api/rest-global-styles-revisions-controller.php index a715899979ad1..f84ee2c4c642c 100644 --- a/tests/phpunit/tests/rest-api/rest-global-styles-revisions-controller.php +++ b/tests/phpunit/tests/rest-api/rest-global-styles-revisions-controller.php @@ -211,17 +211,17 @@ public static function wpTearDownAfterClass() { public function set_up() { parent::set_up(); switch_theme( 'tt1-blocks' ); - $revisions = wp_get_post_revisions( self::$global_styles_id ); + $revisions = array_values( wp_get_post_revisions( self::$global_styles_id ) ); $this->total_revisions = count( $revisions ); - $this->revision_1 = array_pop( $revisions ); - $this->revision_1_id = $this->revision_1->ID; + $this->revision_3 = $revisions[0]; + $this->revision_3_id = $this->revision_3->ID; - $this->revision_2 = array_pop( $revisions ); + $this->revision_2 = $revisions[1]; $this->revision_2_id = $this->revision_2->ID; - $this->revision_3 = array_pop( $revisions ); - $this->revision_3_id = $this->revision_3->ID; + $this->revision_1 = $revisions[2]; + $this->revision_1_id = $this->revision_1->ID; } /** @@ -961,8 +961,8 @@ public function test_get_global_styles_revisions_pagination() { $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); $this->assertCount( 1, $data ); - $this->assertSame( 3, $response->get_headers()['X-WP-Total'] ); - $this->assertSame( 3, $response->get_headers()['X-WP-TotalPages'] ); + $this->assertSame( 4, $response->get_headers()['X-WP-Total'] ); + $this->assertSame( 4, $response->get_headers()['X-WP-TotalPages'] ); // Test paged. $request = new WP_REST_Request( 'GET', '/wp/v2/global-styles/' . self::$global_styles_id . '/revisions' ); @@ -971,8 +971,8 @@ public function test_get_global_styles_revisions_pagination() { $response = rest_get_server()->dispatch( $request ); $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); - $this->assertCount( 1, $data ); - $this->assertSame( 3, $response->get_headers()['X-WP-Total'] ); + $this->assertCount( 2, $data ); + $this->assertSame( 4, $response->get_headers()['X-WP-Total'] ); $this->assertSame( 2, $response->get_headers()['X-WP-TotalPages'] ); // Test out of bounds. @@ -1347,7 +1347,7 @@ public function test_get_items_preserves_block_style_variations() { $data = $response->get_data(); $this->assertSame( 200, $response->get_status(), 'Response status should be 200.' ); - $this->assertCount( 2, $data, 'Should have 2 revisions.' ); + $this->assertCount( 3, $data, 'Should have 3 revisions.' ); // Verify first revision (most recent - orange). $this->assertArrayHasKey( diff --git a/tests/phpunit/tests/rest-api/rest-posts-controller.php b/tests/phpunit/tests/rest-api/rest-posts-controller.php index 212ddde70dd83..7b298ae1de657 100644 --- a/tests/phpunit/tests/rest-api/rest-posts-controller.php +++ b/tests/phpunit/tests/rest-api/rest-posts-controller.php @@ -2250,9 +2250,12 @@ public function test_get_item_links() { $replies_url = add_query_arg( 'post', self::$post_id, $replies_url ); $this->assertSame( $replies_url, $links['replies'][0]['href'] ); + $revisions = wp_get_latest_revision_id_and_total_count( self::$post_id ); + $this->assertSame( rest_url( '/wp/v2/posts/' . self::$post_id . '/revisions' ), $links['version-history'][0]['href'] ); - $this->assertSame( 0, $links['version-history'][0]['attributes']['count'] ); - $this->assertArrayNotHasKey( 'predecessor-version', $links ); + $this->assertSame( 1, $links['version-history'][0]['attributes']['count'] ); + $this->assertSame( rest_url( '/wp/v2/posts/' . self::$post_id . '/revisions/' . $revisions['latest_id'] ), $links['predecessor-version'][0]['href'] ); + $this->assertSame( $revisions['latest_id'], $links['predecessor-version'][0]['attributes']['id'] ); $attachments_url = rest_url( '/wp/v2/media' ); $attachments_url = add_query_arg( 'parent', self::$post_id, $attachments_url ); @@ -2289,8 +2292,8 @@ public function test_get_item_links_predecessor() { 'ID' => self::$post_id, ) ); - $revisions = wp_get_post_revisions( self::$post_id ); - $revision_1 = array_pop( $revisions ); + $revisions = wp_get_post_revisions( self::$post_id ); + $latest_revision = reset( $revisions ); $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/posts/%d', self::$post_id ) ); $response = rest_get_server()->dispatch( $request ); @@ -2298,10 +2301,10 @@ public function test_get_item_links_predecessor() { $links = $response->get_links(); $this->assertSame( rest_url( '/wp/v2/posts/' . self::$post_id . '/revisions' ), $links['version-history'][0]['href'] ); - $this->assertSame( 1, $links['version-history'][0]['attributes']['count'] ); + $this->assertSame( 2, $links['version-history'][0]['attributes']['count'] ); - $this->assertSame( rest_url( '/wp/v2/posts/' . self::$post_id . '/revisions/' . $revision_1->ID ), $links['predecessor-version'][0]['href'] ); - $this->assertSame( $revision_1->ID, $links['predecessor-version'][0]['attributes']['id'] ); + $this->assertSame( rest_url( '/wp/v2/posts/' . self::$post_id . '/revisions/' . $latest_revision->ID ), $links['predecessor-version'][0]['href'] ); + $this->assertSame( $latest_revision->ID, $links['predecessor-version'][0]['attributes']['id'] ); } public function test_get_item_links_no_author() { diff --git a/tests/phpunit/tests/rest-api/wpRestTemplateRevisionsController.php b/tests/phpunit/tests/rest-api/wpRestTemplateRevisionsController.php index e8a18b275e7cd..957ec7dae83be 100644 --- a/tests/phpunit/tests/rest-api/wpRestTemplateRevisionsController.php +++ b/tests/phpunit/tests/rest-api/wpRestTemplateRevisionsController.php @@ -365,54 +365,31 @@ public function test_get_items_with_data_provider( $parent_post_property_name, $ $this->assertSame( WP_Http::OK, $response->get_status(), 'Response is expected to have a status code of 200.' ); $this->assertCount( - 4, + 5, $revisions, - 'Failed asserting that the response data contains exactly 4 items.' + 'Failed asserting that the response data contains exactly 5 items.' ); - $this->assertSame( - $parent_post->ID, - $revisions[0]['parent'], - 'Failed asserting that the parent ID of the revision matches the template post ID.' - ); - $this->assertSame( + $expected_contents = array( 'Content revision #5', - $revisions[0]['content']['raw'], - 'Failed asserting that the content of the revision is "Content revision #5".' - ); - - $this->assertSame( - $parent_post->ID, - $revisions[1]['parent'], - 'Failed asserting that the parent ID of the revision matches the template post ID.' - ); - $this->assertSame( 'Content revision #4', - $revisions[1]['content']['raw'], - 'Failed asserting that the content of the revision is "Content revision #4".' - ); - - $this->assertSame( - $parent_post->ID, - $revisions[2]['parent'], - 'Failed asserting that the parent ID of the revision matches the template post ID.' - ); - $this->assertSame( 'Content revision #3', - $revisions[2]['content']['raw'], - 'Failed asserting that the content of the revision is "Content revision #3".' - ); - - $this->assertSame( - $parent_post->ID, - $revisions[3]['parent'], - 'Failed asserting that the parent ID of the revision matches the template post ID.' - ); - $this->assertSame( 'Content revision #2', - $revisions[3]['content']['raw'], - 'Failed asserting that the content of the revision is "Content revision #2".' + 'Content', ); + + foreach ( $expected_contents as $index => $expected_content ) { + $this->assertSame( + $parent_post->ID, + $revisions[ $index ]['parent'], + 'Failed asserting that the parent ID of the revision matches the template post ID.' + ); + $this->assertSame( + $expected_content, + $revisions[ $index ]['content']['raw'], + 'Failed asserting that the revision content matches the expected content.' + ); + } } /** @@ -1199,8 +1176,8 @@ public function test_get_template_revisions_pagination() { $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); $this->assertCount( 1, $data ); - $this->assertSame( 4, $response->get_headers()['X-WP-Total'] ); - $this->assertSame( 4, $response->get_headers()['X-WP-TotalPages'] ); + $this->assertSame( 5, $response->get_headers()['X-WP-Total'] ); + $this->assertSame( 5, $response->get_headers()['X-WP-TotalPages'] ); // Test paged. $request = new WP_REST_Request( 'GET', '/wp/v2/templates/' . self::TEST_THEME . '/' . self::TEMPLATE_NAME . '/revisions' ); @@ -1210,8 +1187,8 @@ public function test_get_template_revisions_pagination() { $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); $this->assertCount( 2, $data ); - $this->assertSame( 4, $response->get_headers()['X-WP-Total'] ); - $this->assertSame( 2, $response->get_headers()['X-WP-TotalPages'] ); + $this->assertSame( 5, $response->get_headers()['X-WP-Total'] ); + $this->assertSame( 3, $response->get_headers()['X-WP-TotalPages'] ); // Test out of bounds. $request = new WP_REST_Request( 'GET', '/wp/v2/templates/' . self::TEST_THEME . '/' . self::TEMPLATE_NAME . '/revisions' ); From cf9c773351df6f9416a75e0eed28cb87d4af2260 Mon Sep 17 00:00:00 2001 From: Sukhendu Sekhar Guria Date: Wed, 12 Aug 2026 17:43:19 +0530 Subject: [PATCH 3/6] Fix PHPCS errors --- .../rest-api/rest-revisions-controller.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/phpunit/tests/rest-api/rest-revisions-controller.php b/tests/phpunit/tests/rest-api/rest-revisions-controller.php index f967b37c46fcb..a3ec4415fbe44 100644 --- a/tests/phpunit/tests/rest-api/rest-revisions-controller.php +++ b/tests/phpunit/tests/rest-api/rest-revisions-controller.php @@ -19,15 +19,15 @@ class WP_Test_REST_Revisions_Controller extends WP_Test_REST_Controller_Testcase private $revisions; - private WP_Post $revision_1; - private int $revision_id1; - private WP_Post $revision_2; - private int $revision_id2; - private WP_Post $revision_3; - private int $revision_id3; - private WP_Post $revision_initial; - private int $revision_initial_id; - private int $revision_2_1_id; + private WP_Post $revision_1; + private int $revision_id1; + private WP_Post $revision_2; + private int $revision_id2; + private WP_Post $revision_3; + private int $revision_id3; + private WP_Post $revision_initial; + private int $revision_initial_id; + private int $revision_2_1_id; public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) { self::$post_id = $factory->post->create(); From 5746b52663f7ac68780566fac40564c9ac993dcf Mon Sep 17 00:00:00 2001 From: adamsilverstein Date: Sun, 8 Nov 2026 11:01:23 -0500 Subject: [PATCH 4/6] Revisions: Keep the wp_save_post_revision() signature unchanged. The function is often hooked directly, and callbacks registered with more than one accepted arg would pass a post object or ID in as the new `$revision_author`, crediting revisions to the wrong user. Pick the author inside wp_save_post_revision() instead: with no current user and no existing revisions, the first revision is credited to the post author. This also covers a first revision saved on update without a current user, such as a cron edit of an imported post. Also corrects `@since` to 7.3.0, since trunk is 7.2 beta. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_018vwYjUwKmjrEva3fyXVCbp --- src/wp-includes/revision.php | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/wp-includes/revision.php b/src/wp-includes/revision.php index eed171c52ac21..db38ffdc79785 100644 --- a/src/wp-includes/revision.php +++ b/src/wp-includes/revision.php @@ -111,10 +111,7 @@ function wp_save_post_revision_on_insert( $post_id, $post, $update ) { return; } - wp_save_post_revision( - $post_id, - ! $update && 0 === get_current_user_id() ? $post->post_author : null - ); + wp_save_post_revision( $post_id ); } /** @@ -124,13 +121,11 @@ function wp_save_post_revision_on_insert( $post_id, $post, $update ) { * and the most recent revision always matches the current post. * * @since 2.6.0 - * @since 7.1.0 The `$revision_author` parameter was added. * - * @param int $post_id The ID of the post to save as a revision. - * @param int|null $revision_author Optional. The revision author ID. Default null. + * @param int $post_id The ID of the post to save as a revision. * @return int|WP_Error|null Null or 0 if error, new revision ID, if success. */ -function wp_save_post_revision( $post_id, $revision_author = null ) { +function wp_save_post_revision( $post_id ) { if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { return null; } @@ -217,6 +212,15 @@ function wp_save_post_revision( $post_id, $revision_author = null ) { } } + /* + * With no current user (eg. imports or cron), credit the first revision + * to the post author instead of user 0. + */ + $revision_author = null; + if ( ! $revisions && 0 === get_current_user_id() ) { + $revision_author = (int) $post->post_author; + } + $return = _wp_put_post_revision( $post, false, $revision_author ); /* @@ -349,7 +353,7 @@ function wp_is_post_autosave( $post ) { * Inserts post data into the posts table as a post revision. * * @since 2.6.0 - * @since 7.1.0 The `$post_author` parameter was added. + * @since 7.3.0 The `$post_author` parameter was added. * @access private * * @param int|WP_Post|array|null $post Post ID, post object OR post array. From afc34136889b2f9948eafbeaa563bccda40a4416 Mon Sep 17 00:00:00 2001 From: adamsilverstein Date: Sun, 8 Nov 2026 11:01:23 -0500 Subject: [PATCH 5/6] Tests: Skip the initial revision in REST revision meta tests. The revision meta tests added on trunk read the oldest revision, expecting the one saved by the first update. Posts now get a revision on insert, so that is the second oldest. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_018vwYjUwKmjrEva3fyXVCbp --- .../rest-api/rest-revisions-controller.php | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/tests/phpunit/tests/rest-api/rest-revisions-controller.php b/tests/phpunit/tests/rest-api/rest-revisions-controller.php index 3d596c17b936e..c2e7eca523d70 100644 --- a/tests/phpunit/tests/rest-api/rest-revisions-controller.php +++ b/tests/phpunit/tests/rest-api/rest-revisions-controller.php @@ -1428,7 +1428,7 @@ public function test_get_item_meta_only_includes_revisioned_meta_keys() { $this->register_revisioned_and_non_revisioned_meta(); $post_id = $this->create_post_with_revisioned_meta( 'revisioned value' ); - $revision_id = $this->get_oldest_revision_id( $post_id ); + $revision_id = $this->get_first_update_revision_id( $post_id ); wp_set_current_user( self::$editor_id ); $request = new WP_REST_Request( 'GET', '/wp/v2/posts/' . $post_id . '/revisions/' . $revision_id ); @@ -1460,7 +1460,7 @@ public function test_get_items_meta_only_includes_revisioned_meta_keys() { $data = $response->get_data(); $this->assertSame( 200, $response->get_status() ); - $this->assertCount( 2, $data ); + $this->assertCount( 3, $data ); foreach ( $data as $revision ) { $this->assertArrayHasKey( 'revisioned_meta', $revision['meta'], 'Revisioned meta should be included.' ); @@ -1515,7 +1515,7 @@ static function ( $keys ) { 'post_content' => 'Revised content.', ) ); - $revision_id = $this->get_oldest_revision_id( $post_id ); + $revision_id = $this->get_first_update_revision_id( $post_id ); wp_set_current_user( self::$editor_id ); $request = new WP_REST_Request( 'GET', '/wp/v2/posts/' . $post_id . '/revisions/' . $revision_id ); @@ -1556,7 +1556,7 @@ public function test_get_item_meta_uses_rest_name_of_revisioned_meta_keys() { ); $post_id = $this->create_post_with_revisioned_meta( 'revisioned value' ); - $revision_id = $this->get_oldest_revision_id( $post_id ); + $revision_id = $this->get_first_update_revision_id( $post_id ); wp_set_current_user( self::$editor_id ); $request = new WP_REST_Request( 'GET', '/wp/v2/posts/' . $post_id . '/revisions/' . $revision_id ); @@ -1587,7 +1587,7 @@ public function test_restoring_revision_keeps_meta_that_is_not_revisioned() { $post_id = $this->create_post_with_revisioned_meta( 'old value' ); update_post_meta( $post_id, 'revisioned_meta', 'new value' ); update_post_meta( $post_id, 'non_revisioned_meta', 'kept value' ); - $revision_id = $this->get_oldest_revision_id( $post_id ); + $revision_id = $this->get_first_update_revision_id( $post_id ); wp_set_current_user( self::$editor_id ); $response = $this->restore_revision_like_the_block_editor( '/wp/v2/posts/' . $post_id, $revision_id ); @@ -1636,7 +1636,7 @@ public function test_restoring_pattern_revision_keeps_sync_status( $sync_status 'post_content' => 'Latest content.', ) ); - $revision_id = $this->get_oldest_revision_id( $pattern_id ); + $revision_id = $this->get_first_update_revision_id( $pattern_id ); wp_set_current_user( self::$editor_id ); $response = $this->restore_revision_like_the_block_editor( '/wp/v2/blocks/' . $pattern_id, $revision_id ); @@ -1670,7 +1670,7 @@ public function test_get_item_with_non_array_revision_meta_keys_filter() { $this->register_revisioned_and_non_revisioned_meta(); $post_id = $this->create_post_with_revisioned_meta( 'revisioned value' ); - $revision_id = $this->get_oldest_revision_id( $post_id ); + $revision_id = $this->get_first_update_revision_id( $post_id ); add_filter( 'wp_post_revision_meta_keys', '__return_false' ); @@ -1735,15 +1735,17 @@ private function create_post_with_revisioned_meta( $value ) { } /** - * Gets the ID of a post's oldest revision. + * Gets the ID of the revision saved by a post's first update. + * + * Skips the initial revision saved when the post was inserted. * * @param int $post_id Post ID. * @return int Revision ID. */ - private function get_oldest_revision_id( $post_id ) { - $revisions = wp_get_post_revisions( $post_id ); + private function get_first_update_revision_id( $post_id ) { + $revisions = array_values( wp_get_post_revisions( $post_id, array( 'order' => 'ASC' ) ) ); - return end( $revisions )->ID; + return $revisions[1]->ID; } /** From f863fa359d979a1d555048c31ea0983e9de0c370 Mon Sep 17 00:00:00 2001 From: adamsilverstein Date: Sun, 8 Nov 2026 14:30:11 -0500 Subject: [PATCH 6/6] Tests: Regenerate the REST API client fixtures. Posts now get a revision on insert, so the fixture post reports one more revision and the revisions collection includes the initial one. Taken from the CI diff so the generated IDs match. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_018vwYjUwKmjrEva3fyXVCbp --- tests/qunit/fixtures/wp-api-generated.js | 68 ++++++++++++++++++++++-- 1 file changed, 64 insertions(+), 4 deletions(-) diff --git a/tests/qunit/fixtures/wp-api-generated.js b/tests/qunit/fixtures/wp-api-generated.js index 807eda9d2cf92..c764dba73ced0 100644 --- a/tests/qunit/fixtures/wp-api-generated.js +++ b/tests/qunit/fixtures/wp-api-generated.js @@ -13418,7 +13418,7 @@ mockedApiResponse.PostsCollection = [ ], "version-history": [ { - "count": 2, + "count": 3, "href": "http://example.org/index.php?rest_route=/wp/v2/posts/4/revisions" } ], @@ -13565,6 +13565,36 @@ mockedApiResponse.postRevisions = [ } ] } + }, + { + "author": 674, + "date": "2017-02-14T00:00:00", + "date_gmt": "2017-02-14T00:00:00", + "id": 4202885, + "modified": "2017-02-14T00:00:00", + "modified_gmt": "2017-02-14T00:00:00", + "parent": 4202884, + "slug": "4202884-revision-v1", + "guid": { + "rendered": "http://example.org/?p=4202885" + }, + "title": { + "rendered": "REST API Client Fixture: Post" + }, + "content": { + "rendered": "

REST API Client Fixture: Post

\n" + }, + "excerpt": { + "rendered": "

REST API Client Fixture: Post

\n" + }, + "meta": [], + "_links": { + "parent": [ + { + "href": "http://example.org/index.php?rest_route=/wp/v2/posts/4202884" + } + ] + } } ]; @@ -13584,7 +13614,7 @@ mockedApiResponse.revision = { "rendered": "REST API Client Fixture: Post" }, "content": { - "rendered": "

Updated post content.

\n" + "rendered": "

REST API Client Fixture: Post

\n" }, "excerpt": { "rendered": "

REST API Client Fixture: Post

\n" @@ -13724,7 +13754,7 @@ mockedApiResponse.PagesCollection = [ ], "version-history": [ { - "count": 2, + "count": 3, "href": "http://example.org/index.php?rest_route=/wp/v2/pages/7/revisions" } ], @@ -13853,6 +13883,36 @@ mockedApiResponse.pageRevisions = [ } ] } + }, + { + "author": 674, + "date": "2017-02-14T00:00:00", + "date_gmt": "2017-02-14T00:00:00", + "id": 4202889, + "modified": "2017-02-14T00:00:00", + "modified_gmt": "2017-02-14T00:00:00", + "parent": 4202888, + "slug": "4202888-revision-v1", + "guid": { + "rendered": "http://example.org/?p=4202889" + }, + "title": { + "rendered": "REST API Client Fixture: Page" + }, + "content": { + "rendered": "

REST API Client Fixture: Page

\n" + }, + "excerpt": { + "rendered": "

REST API Client Fixture: Page

\n" + }, + "meta": [], + "_links": { + "parent": [ + { + "href": "http://example.org/index.php?rest_route=/wp/v2/pages/4202888" + } + ] + } } ]; @@ -13872,7 +13932,7 @@ mockedApiResponse.pageRevision = { "rendered": "REST API Client Fixture: Page" }, "content": { - "rendered": "

Updated page content.

\n" + "rendered": "

REST API Client Fixture: Page

\n" }, "excerpt": { "rendered": "

REST API Client Fixture: Page

\n"