From 95243d210684bca4e9752c707601ce9f471eb303 Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Wed, 12 Feb 2014 04:49:15 +0000 Subject: [PATCH] Don't iterate over `$wp_query->posts` in `update_post_thumbnail_cache()` if it is empty. Adds unit tests. Props SergeyBiryukov, for the original patch. Fixes #26321. Built from https://develop.svn.wordpress.org/trunk@27166 git-svn-id: http://core.svn.wordpress.org/trunk@27032 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/post-thumbnail-template.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wp-includes/post-thumbnail-template.php b/wp-includes/post-thumbnail-template.php index 91201e7994..64c8494ca6 100644 --- a/wp-includes/post-thumbnail-template.php +++ b/wp-includes/post-thumbnail-template.php @@ -57,7 +57,7 @@ function update_post_thumbnail_cache( $wp_query = null ) { if ( ! $wp_query ) $wp_query = $GLOBALS['wp_query']; - if ( $wp_query->thumbnails_cached ) + if ( $wp_query->thumbnails_cached || ! $wp_query->posts ) return; $thumb_ids = array(); @@ -69,7 +69,7 @@ function update_post_thumbnail_cache( $wp_query = null ) { if ( ! empty ( $thumb_ids ) ) { _prime_post_caches( $thumb_ids, false, true ); } - + $wp_query->thumbnails_cached = true; }