Make WordPress Core

Ticket #30854: 30854.4.diff

File 30854.4.diff, 2.4 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..9db8eef968 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 );
     404add_action( 'new_to_publish', 'wp_save_post_revision', 10, 1 );
    404405add_action( 'publish_post', '_publish_post_hook', 5, 1 );
    405406add_action( 'transition_post_status', '_transition_post_status', 5, 3 );
    406407add_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..4b43e8b380 100644
    class Tests_Post_Revisions extends WP_UnitTestCase { 
    654654
    655655                $this->assertWPError( $revision );
    656656        }
     657
     658        /**
     659         * @ticket 30854
     660         */
     661        function test_wp_first_revision_is_not_lost() {
     662                $post = self::factory()->post->create_and_get( array(
     663                        'post_title' => 'some-post',
     664                        'post_type' => 'post',
     665                        'post_content' => 'Initial Content',
     666                ) );
     667
     668                wp_update_post( array(
     669                        'ID' => $post->ID,
     670                        'post_content' => 'Update #1',
     671                ) );
     672
     673                wp_update_post( array(
     674                        'ID' => $post->ID,
     675                        'post_content' => 'Update #2',
     676                ) );
     677
     678                $revisions = wp_get_post_revisions( $post->ID );
     679                $earliest_revision = end( $revisions );
     680
     681                $this->assertEquals( 'Initial Content', $earliest_revision->post_content );
     682        }
    657683}