WordPress.org

Make WordPress Core

Ticket #5185: query.diff

File query.diff, 793 bytes (added by ruckus, 7 years ago)

Protect against using unset $this->posts

  • wp-includes/query.php

     
    12721272                // Raw results filter.  Prior to status checks. 
    12731273                $this->posts = apply_filters('posts_results', $this->posts); 
    12741274 
    1275                 if ( $this->is_comment_feed && $this->is_singular ) { 
     1275                if ( !empty($this->posts) && $this->is_comment_feed && $this->is_singular ) { 
    12761276                        $cjoin = apply_filters('comment_feed_join', ''); 
    12771277                        $cwhere = apply_filters('comment_feed_where', "WHERE comment_post_ID = {$this->posts[0]->ID} AND comment_approved = '1'"); 
    12781278                        $comments_request = "SELECT $wpdb->comments.* FROM $wpdb->comments $cjoin $cwhere ORDER BY comment_date_gmt DESC LIMIT " . get_option('posts_per_rss');