From 361ecbb4527da8bae684a37df73c81d11208407f Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Wed, 17 Oct 2012 20:57:23 +0000 Subject: [PATCH] If posts is an empty array, bail from set_found_posts(). If posts is null or otherwise empty proceed through set_found_posts(). This accommodates caching plugins such as Advanced Post Cache that force posts to be empty for later population but still require the found_posts_query filter to run. fixes #14426 git-svn-id: https://develop.svn.wordpress.org/trunk@22258 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/query.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/wp-includes/query.php b/wp-includes/query.php index c48452d67b..3a33bf9446 100644 --- a/wp-includes/query.php +++ b/wp-includes/query.php @@ -2799,7 +2799,9 @@ class WP_Query { function set_found_posts( $q, $limits ) { global $wpdb; - if ( $q['no_found_rows'] || ! $this->posts ) + // Bail if posts is an empty array. Continue if posts is an empty string + // null, or false to accommodate caching plugins that fill posts later. + if ( $q['no_found_rows'] || ( is_array( $this->posts ) && ! $this->posts ) ) return; if ( ! empty( $limits ) )