Make WordPress Core


Ignore:
Timestamp:
01/16/2015 04:45:21 PM (10 years ago)
Author:
boonebgorges
Message:

Bail out of hierarchy loops in _pad_term_counts().

Taxonomy hierarchy loops should not occur naturally, but when they do, the
logic of _pad_term_counts() could result in infinite loops, leading to
timeouts. We avoid this by breaking when a loop is detected.

Fixes #20635.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/taxonomy.php

    r31168 r31206  
    39173917
    39183918    // Touch every ancestor's lookup row for each post in each term
     3919    $ancestors = array();
    39193920    foreach ( $term_ids as $term_id ) {
     3921        $ancestors[] = $term_id;
    39203922        $child = $term_id;
    39213923        while ( !empty( $terms_by_id[$child] ) && $parent = $terms_by_id[$child]->parent ) {
     3924            if ( in_array( $parent, $ancestors ) ) {
     3925                break;
     3926            }
     3927
    39223928            if ( !empty( $term_items[$term_id] ) )
    39233929                foreach ( $term_items[$term_id] as $item_id => $touches ) {
Note: See TracChangeset for help on using the changeset viewer.