Make WordPress Core

Ticket #5305: 5305.20.diff

File 5305.20.diff, 1.4 KB (added by boonebgorges, 9 years ago)
  • src/wp-includes/post.php

    diff --git src/wp-includes/post.php src/wp-includes/post.php
    index f15c9e2..912a03c 100644
    function wp_insert_post( $postarr, $wp_error = false ) { 
    34553455        if ( empty( $data['post_name'] ) && ! in_array( $data['post_status'], array( 'draft', 'pending', 'auto-draft' ) ) ) {
    34563456                $data['post_name'] = wp_unique_post_slug( sanitize_title( $data['post_title'], $post_ID ), $post_ID, $data['post_status'], $post_type, $post_parent );
    34573457                $wpdb->update( $wpdb->posts, array( 'post_name' => $data['post_name'] ), $where );
     3458                clean_post_cache( $post_ID );
    34583459        }
    34593460
    34603461        if ( is_object_in_taxonomy( $post_type, 'category' ) ) {
  • tests/phpunit/tests/post.php

    diff --git tests/phpunit/tests/post.php tests/phpunit/tests/post.php
    index 22310c0..d51b546 100644
    class Tests_Post extends WP_UnitTestCase { 
    435435        }
    436436
    437437        /**
     438         * @ticket 5305
     439         * @ticket 33392
     440         */
     441        public function test_wp_insert_post_should_invalidate_post_cache_before_generating_guid_when_post_name_is_empty_and_is_generated_from_the_post_ID(){
     442                register_post_type( 'wptests_pt' );
     443
     444                $p = wp_insert_post( array(
     445                        'post_title' => '',
     446                        'post_type' => 'wptests_pt',
     447                        'post_status' => 'publish',
     448                ) );
     449
     450                $post = get_post( $p );
     451
     452                $this->assertContains( 'wptests_pt=' . $p, $post->guid );
     453        }
     454
     455        /**
    438456         * @ticket 5364
    439457         */
    440458        function test_delete_future_post_cron() {