WordPress.org

Make WordPress Core

Ticket #9635: comment_query_filters._consistent_prefix.9635.diff

File comment_query_filters._consistent_prefix.9635.diff, 2.7 KB (added by filosofo, 6 years ago)
  • wp-includes/query.php

     
    21702170                        if ( $this->is_archive || $this->is_search ) { 
    21712171                                $cjoin = "LEFT JOIN $wpdb->posts ON ($wpdb->comments.comment_post_ID = $wpdb->posts.ID) $join "; 
    21722172                                $cwhere = "WHERE comment_approved = '1' $where"; 
    2173                                 $cgroupby = "GROUP BY $wpdb->comments.comment_id"; 
     2173                                $cgroupby = "$wpdb->comments.comment_id"; 
    21742174                        } else { // Other non singular e.g. front 
    21752175                                $cjoin = "LEFT JOIN $wpdb->posts ON ( $wpdb->comments.comment_post_ID = $wpdb->posts.ID )"; 
    21762176                                $cwhere = "WHERE post_status = 'publish' AND comment_approved = '1'"; 
     
    21812181                                $cjoin = apply_filters('comment_feed_join', $cjoin); 
    21822182                                $cwhere = apply_filters('comment_feed_where', $cwhere); 
    21832183                                $cgroupby = apply_filters('comment_feed_groupby', $cgroupby); 
     2184                                $corderby = apply_filters('comment_feed_orderby', 'comment_date_gmt DESC'); 
     2185                                $climits = apply_filters('comment_feed_limits', 'LIMIT ' . get_option('posts_per_rss')); 
    21842186                        } 
     2187                        $cgroupby = ( ! empty( $cgroupby ) ) ? 'GROUP BY ' . $cgroupby : ''; 
     2188                        $corderby = ( ! empty( $corderby ) ) ? 'ORDER BY ' . $corderby : ''; 
    21852189 
    2186                         $this->comments = (array) $wpdb->get_results("SELECT $distinct $wpdb->comments.* FROM $wpdb->comments $cjoin $cwhere $cgroupby ORDER BY comment_date_gmt DESC LIMIT " . get_option('posts_per_rss')); 
     2190                        $this->comments = (array) $wpdb->get_results("SELECT $distinct $wpdb->comments.* FROM $wpdb->comments $cjoin $cwhere $cgroupby $corderby $climits"); 
    21872191                        $this->comment_count = count($this->comments); 
    21882192 
    21892193                        $post_ids = array(); 
     
    22482252                if ( !empty($this->posts) && $this->is_comment_feed && $this->is_singular ) { 
    22492253                        $cjoin = apply_filters('comment_feed_join', ''); 
    22502254                        $cwhere = apply_filters('comment_feed_where', "WHERE comment_post_ID = '{$this->posts[0]->ID}' AND comment_approved = '1'"); 
    2251                         $comments_request = "SELECT $wpdb->comments.* FROM $wpdb->comments $cjoin $cwhere ORDER BY comment_date_gmt DESC LIMIT " . get_option('posts_per_rss'); 
     2255                        $cgroupby = apply_filters('comment_feed_groupby', ''); 
     2256                        $cgroupby = ( ! empty( $cgroupby ) ) ? 'GROUP BY ' . $cgroupby : ''; 
     2257                        $corderby = apply_filters('comment_feed_orderby', 'comment_date_gmt DESC'); 
     2258                        $corderby = ( ! empty( $corderby ) ) ? 'ORDER BY ' . $corderby : ''; 
     2259                        $climits = apply_filters('comment_feed_limits', 'LIMIT ' . get_option('posts_per_rss')); 
     2260                        $comments_request = "SELECT $wpdb->comments.* FROM $wpdb->comments $cjoin $cwhere $cgroupby $corderby $climits"; 
    22522261                        $this->comments = $wpdb->get_results($comments_request); 
    22532262                        $this->comment_count = count($this->comments); 
    22542263                }