Ticket #18536: 18536-ancestors.diff
File 18536-ancestors.diff, 1.0 KB (added by , 13 years ago) |
---|
-
wp-includes/post.php
430 430 function get_post_ancestors($post) { 431 431 $post = get_post($post); 432 432 433 if ( !empty($post->ancestors) ) 433 if ( ! isset( $post->ancestors ) ) 434 _get_post_ancestors( $post ); 435 436 if ( ! empty( $post->ancestors ) ) 434 437 return $post->ancestors; 435 438 436 439 return array(); … … 4645 4648 if ( empty($_post->post_parent) || $_post->ID == $_post->post_parent ) 4646 4649 return; 4647 4650 4648 $id = $_post->ancestors[] = $_post->post_parent;4651 $id = $_post->ancestors[] = (int) $_post->post_parent; 4649 4652 while ( $ancestor = $wpdb->get_var( $wpdb->prepare("SELECT `post_parent` FROM $wpdb->posts WHERE ID = %d LIMIT 1", $id) ) ) { 4650 4653 // Loop detection: If the ancestor has been seen before, break. 4651 4654 if ( ( $ancestor == $_post->ID ) || in_array($ancestor, $_post->ancestors) ) 4652 4655 break; 4653 $id = $_post->ancestors[] = $ancestor;4656 $id = $_post->ancestors[] = (int) $ancestor; 4654 4657 } 4655 4658 } 4656 4659