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
This commit is contained in:
ryan 2008-01-29 19:01:39 +00:00
parent 520d17d7f0
commit 7f4b870b15
1 changed files with 2 additions and 2 deletions

View File

@ -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);