Some more hierarchy loop detection.

git-svn-id: http://svn.automattic.com/wordpress/trunk@15758 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2010-10-08 16:22:14 +00:00
parent b0c538b9f1
commit 76c787d4d2

View File

@ -4019,8 +4019,12 @@ function clean_post_cache($id) {
do_action('clean_post_cache', $id);
if ( $children = $wpdb->get_col( $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_parent = %d", $id) ) ) {
foreach( $children as $cid )
foreach ( $children as $cid ) {
// Loop detection
if ( $cid == $id )
continue;
clean_post_cache( $cid );
}
}
if ( is_multisite() )
@ -4325,7 +4329,8 @@ function _get_post_ancestors(&$_post) {
$id = $_post->ancestors[] = $_post->post_parent;
while ( $ancestor = $wpdb->get_var( $wpdb->prepare("SELECT `post_parent` FROM $wpdb->posts WHERE ID = %d LIMIT 1", $id) ) ) {
if ( $id == $ancestor )
// Loop detection: If the ancestor has been seen before, break.
if ( ( $ancestor == $_post->ID ) || in_array($ancestor, $_post->ancestors) )
break;
$id = $_post->ancestors[] = $ancestor;
}