diff --git a/wp-includes/taxonomy.php b/wp-includes/taxonomy.php index 078e04f868..77d53dce9e 100644 --- a/wp-includes/taxonomy.php +++ b/wp-includes/taxonomy.php @@ -3920,20 +3920,20 @@ function _pad_term_counts(&$terms, $taxonomy) { } // Touch every ancestor's lookup row for each post in each term - $ancestors = array(); foreach ( $term_ids as $term_id ) { - $ancestors[] = $term_id; $child = $term_id; + $ancestors = array(); while ( !empty( $terms_by_id[$child] ) && $parent = $terms_by_id[$child]->parent ) { - if ( in_array( $parent, $ancestors ) ) { - break; - } - + $ancestors[] = $child; if ( !empty( $term_items[$term_id] ) ) foreach ( $term_items[$term_id] as $item_id => $touches ) { $term_items[$parent][$item_id] = isset($term_items[$parent][$item_id]) ? ++$term_items[$parent][$item_id]: 1; } $child = $parent; + + if ( in_array( $parent, $ancestors ) ) { + break; + } } } diff --git a/wp-includes/version.php b/wp-includes/version.php index e941e9d921..637e278f92 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.2-alpha-31247'; +$wp_version = '4.2-alpha-31248'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.