WordPress.org

Make WordPress Core

Changeset 20171


Ignore:
Timestamp:
03/12/12 18:23:48 (2 years ago)
Author:
ryan
Message:

Call _get_post_ancestors() from get_post_ancestors() if the ancestors property is not set in the post object. Works around situations where ancestors is not set in the cached version of the post object. see #18536

Location:
trunk/wp-includes
Files:
2 edited

Legend:

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

    r20156 r20171  
    431431    $post = get_post($post); 
    432432 
    433     if ( !empty($post->ancestors) ) 
     433    if ( ! isset( $post->ancestors ) ) 
     434        _get_post_ancestors( $post ); 
     435 
     436    if ( ! empty( $post->ancestors ) ) 
    434437        return $post->ancestors; 
    435438 
     
    46464649        return; 
    46474650 
    4648     $id = $_post->ancestors[] = $_post->post_parent; 
     4651    $id = $_post->ancestors[] = (int) $_post->post_parent; 
    46494652    while ( $ancestor = $wpdb->get_var( $wpdb->prepare("SELECT `post_parent` FROM $wpdb->posts WHERE ID = %d LIMIT 1", $id) ) ) { 
    46504653        // Loop detection: If the ancestor has been seen before, break. 
    46514654        if ( ( $ancestor == $_post->ID ) || in_array($ancestor,  $_post->ancestors) ) 
    46524655            break; 
    4653         $id = $_post->ancestors[] = $ancestor; 
     4656        $id = $_post->ancestors[] = (int) $ancestor; 
    46544657    } 
    46554658} 
  • trunk/wp-includes/query.php

    r20024 r20171  
    26722672        // Check post status to determine if post should be displayed. 
    26732673        if ( !empty($this->posts) && ($this->is_single || $this->is_page) ) { 
    2674             $status = get_post_status($this->posts[0]); 
     2674            $status = get_post_status($this->posts[0]->ID); 
    26752675            $post_status_obj = get_post_status_object($status); 
    26762676            //$type = get_post_type($this->posts[0]); 
Note: See TracChangeset for help on using the changeset viewer.