From f6fced867b2956337e33faa4d0baac4e501612d6 Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Sun, 21 Aug 2016 06:24:18 +0000 Subject: [PATCH] Comments: in `WP_Comment_Query::fill_descendants()`, compute `count()` in the first `for` expression so that it does not run on each iteration. Props vishalkakadiya, deremohan. Fixes #37416. git-svn-id: https://develop.svn.wordpress.org/trunk@38297 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/class-wp-comment-query.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-includes/class-wp-comment-query.php b/src/wp-includes/class-wp-comment-query.php index f2ccc832e7..c8fed2586a 100644 --- a/src/wp-includes/class-wp-comment-query.php +++ b/src/wp-includes/class-wp-comment-query.php @@ -1012,7 +1012,7 @@ class WP_Comment_Query { // Prime comment caches for non-top-level comments. $descendant_ids = array(); - for ( $i = 1; $i < count( $levels ); $i++ ) { + for ( $i = 1, $c = count( $levels ); $i <= $c; $i++ ) { $descendant_ids = array_merge( $descendant_ids, $levels[ $i ] ); }