Make WordPress Core

Ticket #30854: 30854.7.diff

File 30854.7.diff, 3.7 KB (added by adamsilverstein, 4 years ago)
  • src/wp-includes/default-filters.php

    diff --git src/wp-includes/default-filters.php src/wp-includes/default-filters.php
    index a446eed1c2..9c65467080 100644
    add_action( 'plugins_loaded', 'wp_maybe_load_embeds', 0 ); 
    401401add_action( 'shutdown', 'wp_ob_end_flush_all', 1 );
    402402// Create a revision whenever a post is updated.
    403403add_action( 'post_updated', 'wp_save_post_revision', 10, 1 );
     404// Fired in `wp_transition_post_status` for newly created posts with status 'publish'.
     405add_action( 'new_to_publish', 'wp_save_post_revision', 10, 1 );
    404406add_action( 'publish_post', '_publish_post_hook', 5, 1 );
    405407add_action( 'transition_post_status', '_transition_post_status', 5, 3 );
    406408add_action( 'transition_post_status', '_update_term_count_on_transition_post_status', 10, 3 );
  • src/wp-includes/theme.php

    diff --git src/wp-includes/theme.php src/wp-includes/theme.php
    index a7bc431c37..1770e6cb52 100644
    function wp_update_custom_css_post( $css, $args = array() ) { 
    20172017        } else {
    20182018                $r = wp_insert_post( wp_slash( $post_data ), true );
    20192019
    2020                 if ( ! is_wp_error( $r ) ) {
    2021                         if ( get_stylesheet() === $args['stylesheet'] ) {
    2022                                 set_theme_mod( 'custom_css_post_id', $r );
    2023                         }
    2024 
    2025                         // Trigger creation of a revision. This should be removed once #30854 is resolved.
    2026                         if ( 0 === count( wp_get_post_revisions( $r ) ) ) {
    2027                                 wp_save_post_revision( $r );
    2028                         }
     2020                if ( ! is_wp_error( $r ) && get_stylesheet() === $args['stylesheet'] ) {
     2021                        set_theme_mod( 'custom_css_post_id', $r );
    20292022                }
    20302023        }
    20312024
  • tests/phpunit/tests/post/revisions.php

    diff --git tests/phpunit/tests/post/revisions.php tests/phpunit/tests/post/revisions.php
    index 35e43f18ae..392d09a1bb 100644
    class Tests_Post_Revisions extends WP_UnitTestCase { 
    538538                }
    539539
    540540                $revisions = wp_get_post_revisions( $post['ID'] );
    541 
     541                array_unshift( $revision_ids, reset( $revisions )->ID );
    542542                $this->assertSame( $revision_ids, array_values( wp_list_pluck( $revisions, 'ID' ) ) );
    543543        }
    544544
    class Tests_Post_Revisions extends WP_UnitTestCase { 
    574574
    575575                $revisions = wp_get_post_revisions( $post['ID'] );
    576576
     577                array_unshift( $revision_ids, reset( $revisions )->ID );
     578
    577579                $this->assertSame( $revision_ids, array_values( wp_list_pluck( $revisions, 'ID' ) ) );
    578580        }
    579581
    class Tests_Post_Revisions extends WP_UnitTestCase { 
    654656
    655657                $this->assertWPError( $revision );
    656658        }
     659
     660        /**
     661         * @ticket 30854
     662         */
     663        function test_wp_first_revision_is_not_lost() {
     664                $post = self::factory()->post->create_and_get(
     665                        array(
     666                                'post_title'   => 'some-post',
     667                                'post_type'    => 'post',
     668                                'post_content' => 'Initial Content',
     669                        )
     670                );
     671
     672                wp_update_post(
     673                        array(
     674                                'ID'           => $post->ID,
     675                                'post_content' => 'Update #1',
     676                        )
     677                );
     678
     679                wp_update_post(
     680                        array(
     681                                'ID'           => $post->ID,
     682                                'post_content' => 'Update #2',
     683                        )
     684                );
     685
     686                $revisions         = wp_get_post_revisions( $post->ID );
     687                $earliest_revision = end( $revisions );
     688
     689                $this->assertEquals( 'Initial Content', $earliest_revision->post_content );
     690        }
    657691}
  • tests/phpunit/tests/xmlrpc/wp/getRevisions.php

    diff --git tests/phpunit/tests/xmlrpc/wp/getRevisions.php tests/phpunit/tests/xmlrpc/wp/getRevisions.php
    index b7a4667165..03814bc7bf 100644
    class Tests_XMLRPC_wp_getRevisions extends WP_XMLRPC_UnitTestCase { 
    4242
    4343                $result = $this->myxmlrpcserver->wp_getRevisions( array( 1, 'editor', 'editor', $post_id ) );
    4444                $this->assertIsArray( $result );
    45                 $this->assertCount( 1, $result );
     45                $this->assertCount( 2, $result );
    4646
    4747                wp_insert_post(
    4848                        array(