From 7f4b870b15bca6af559e33aa100813a4e85c9e25 Mon Sep 17 00:00:00 2001 From: ryan 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: http://svn.automattic.com/wordpress/trunk@6683 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- 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 f6bf038e8..32ff5c530 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);