Make WordPress Core

Changeset 19734


Ignore:
Timestamp:
01/13/2012 06:37:46 PM (14 years ago)
Author:
duck_
Message:

Update hierarchy for all hierarchical post types when deleting a parent post, not just for pages. Fixes #19637.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/post.php

    r19729 r19734  
    19851985    $parent_where = array( 'post_parent' => $postid );
    19861986
     1987    if ( is_post_type_hierarchical( $post->post_type ) ) {
     1988        // Point children of this page to its parent, also clean the cache of affected children
     1989        $children_query = $wpdb->prepare( "SELECT * FROM $wpdb->posts WHERE post_parent = %d AND post_type = %s", $postid, $post->post_type );
     1990        $children = $wpdb->get_results( $children_query );
     1991
     1992        $wpdb->update( $wpdb->posts, $parent_data, $parent_where + array( 'post_type' => $post->post_type ) );
     1993    }
     1994
    19871995    if ( 'page' == $post->post_type) {
    19881996        // if the page is defined in option page_on_front or post_for_posts,
     
    19952003            delete_option('page_for_posts');
    19962004        }
    1997 
    1998         // Point children of this page to its parent, also clean the cache of affected children
    1999         $children_query = $wpdb->prepare("SELECT * FROM $wpdb->posts WHERE post_parent = %d AND post_type='page'", $postid);
    2000         $children = $wpdb->get_results($children_query);
    2001 
    2002         $wpdb->update( $wpdb->posts, $parent_data, $parent_where + array( 'post_type' => 'page' ) );
    20032005    } else {
    20042006        unstick_post($postid);
     
    20362038    if ( 'page' == $post->post_type ) {
    20372039        clean_page_cache($postid);
    2038 
    2039         foreach ( (array) $children as $child )
    2040             clean_page_cache($child->ID);
    20412040    } else {
    20422041        clean_post_cache($postid);
     2042    }
     2043
     2044    if ( is_post_type_hierarchical( $post->post_type ) ) {
     2045        foreach ( (array) $children as $child )
     2046            clean_post_cache( $child->ID );
    20432047    }
    20442048
Note: See TracChangeset for help on using the changeset viewer.