WP_Comment_Query: Fill comment objects from database when cache is unavailable.

This fixes a bug where widgets loaded in a preview or the Customizer are
rendered inside of a `wp_suspend_cache_addition()` block and thus could not
find comment objects in the cache.

Props rommelxcastro, stevehenty.
Fixes #34138.

git-svn-id: https://develop.svn.wordpress.org/trunk@35512 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Boone Gorges
2015-11-04 21:09:01 +00:00
parent 74b68afa3f
commit c8dd2d480d
2 changed files with 46 additions and 1 deletions

View File

@@ -412,7 +412,7 @@ class WP_Comment_Query {
// Fetch full comment objects from the primed cache.
$_comments = array();
foreach ( $comment_ids as $comment_id ) {
if ( $_comment = wp_cache_get( $comment_id, 'comment' ) ) {
if ( $_comment = get_comment( $comment_id ) ) {
$_comments[] = $_comment;
}
}