Make WordPress Core


Ignore:
Timestamp:
01/19/2015 04:51:44 PM (9 years ago)
Author:
boonebgorges
Message:

Better loop detection for _pad_term_counts().

The $ancestors check must be reset for each term in order for term counts
to be correct.

Fixes #20635.

File:
1 edited

Legend:

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

    r31238 r31248  
    39213921
    39223922    // Touch every ancestor's lookup row for each post in each term
    3923     $ancestors = array();
    39243923    foreach ( $term_ids as $term_id ) {
    3925         $ancestors[] = $term_id;
    39263924        $child = $term_id;
     3925        $ancestors = array();
    39273926        while ( !empty( $terms_by_id[$child] ) && $parent = $terms_by_id[$child]->parent ) {
    3928             if ( in_array( $parent, $ancestors ) ) {
    3929                 break;
    3930             }
    3931 
     3927            $ancestors[] = $child;
    39323928            if ( !empty( $term_items[$term_id] ) )
    39333929                foreach ( $term_items[$term_id] as $item_id => $touches ) {
     
    39353931                }
    39363932            $child = $parent;
     3933
     3934            if ( in_array( $parent, $ancestors ) ) {
     3935                break;
     3936            }
    39373937        }
    39383938    }
Note: See TracChangeset for help on using the changeset viewer.