From 7195355b63730cb60bfef43446d03e4a3df63b40 Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Tue, 29 Jan 2008 19:01:39 +0000 Subject: [PATCH] Make sure we have a post when doing post comment feed query. Props ruckus. see #5185 git-svn-id: https://develop.svn.wordpress.org/trunk@6683 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/query.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wp-includes/query.php b/wp-includes/query.php index f6bf038e8c..32ff5c530c 100644 --- a/wp-includes/query.php +++ b/wp-includes/query.php @@ -1282,9 +1282,9 @@ class WP_Query { // Raw results filter. Prior to status checks. $this->posts = apply_filters('posts_results', $this->posts); - if ( $this->is_comment_feed && $this->is_singular ) { + if ( !empty($this->posts) && $this->is_comment_feed && $this->is_singular ) { $cjoin = apply_filters('comment_feed_join', ''); - $cwhere = apply_filters('comment_feed_where', "WHERE comment_post_ID = {$this->posts[0]->ID} AND comment_approved = '1'"); + $cwhere = apply_filters('comment_feed_where', "WHERE comment_post_ID = '{$this->posts[0]->ID}' AND comment_approved = '1'"); $comments_request = "SELECT $wpdb->comments.* FROM $wpdb->comments $cjoin $cwhere ORDER BY comment_date_gmt DESC LIMIT " . get_option('posts_per_rss'); $this->comments = $wpdb->get_results($comments_request); $this->comment_count = count($this->comments);