WordPress.org

Make WordPress Core

Changeset 15758


Ignore:
Timestamp:
10/08/2010 04:22:14 PM (9 years ago)
Author:
ryan
Message:

Some more hierarchy loop detection.

File:
1 edited

Legend:

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

    r15742 r15758  
    40204020
    40214021    if ( $children = $wpdb->get_col( $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_parent = %d", $id) ) ) {
    4022         foreach( $children as $cid )
     4022        foreach ( $children as $cid ) {
     4023            // Loop detection
     4024            if ( $cid == $id )
     4025                continue;
    40234026            clean_post_cache( $cid );
     4027        }
    40244028    }
    40254029
     
    43264330    $id = $_post->ancestors[] = $_post->post_parent;
    43274331    while ( $ancestor = $wpdb->get_var( $wpdb->prepare("SELECT `post_parent` FROM $wpdb->posts WHERE ID = %d LIMIT 1", $id) ) ) {
    4328         if ( $id == $ancestor )
     4332        // Loop detection: If the ancestor has been seen before, break.
     4333        if ( ( $ancestor == $_post->ID ) || in_array($ancestor,  $_post->ancestors) )
    43294334            break;
    43304335        $id = $_post->ancestors[] = $ancestor;
Note: See TracChangeset for help on using the changeset viewer.