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. Built from https://develop.svn.wordpress.org/trunk@31206 git-svn-id: http://core.svn.wordpress.org/trunk@31187 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
86f29795a4
commit
991bfdebc1
|
@ -3916,9 +3916,15 @@ 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;
|
||||
while ( !empty( $terms_by_id[$child] ) && $parent = $terms_by_id[$child]->parent ) {
|
||||
if ( in_array( $parent, $ancestors ) ) {
|
||||
break;
|
||||
}
|
||||
|
||||
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;
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '4.2-alpha-31205';
|
||||
$wp_version = '4.2-alpha-31206';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue