Make WordPress Core


Ignore:
Timestamp:
12/07/2015 05:46:35 PM (9 years ago)
Author:
joehoyle
Message:

Prevent unnecessary $wpdb->update() when hierarchical post doesn't have children.

Props danielbachhuber.
Fixes #34896.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/post.php

    r35800 r35817  
    12541254        $this->assertEquals($post['post_date_gmt'], $out->post_date_gmt);
    12551255    }
     1256
     1257    function test_wp_delete_post_reassign_hierarchical_post_type() {
     1258        $grandparent_page_id = self::factory()->post->create( array( 'post_type' => 'page' ) );
     1259        $parent_page_id = self::factory()->post->create( array( 'post_type' => 'page', 'post_parent' => $grandparent_page_id ) );
     1260        $page_id = self::factory()->post->create( array( 'post_type' => 'page', 'post_parent' => $parent_page_id ) );
     1261        $this->assertEquals( $parent_page_id, get_post( $page_id )->post_parent );
     1262        wp_delete_post( $parent_page_id, true );
     1263        $this->assertEquals( $grandparent_page_id, get_post( $page_id )->post_parent );
     1264        wp_delete_post( $grandparent_page_id, true );
     1265        $this->assertEquals( 0, get_post( $page_id )->post_parent );
     1266    }
     1267
    12561268}
Note: See TracChangeset for help on using the changeset viewer.