WordPress.org

Make WordPress Core

Ticket #29902: comments_orderby.diff

File comments_orderby.diff, 631 bytes (added by psycleuk, 7 years ago)
  • wp-includes/comment.php

     
    511511                if ( $groupby ) {
    512512                        $groupby = 'GROUP BY ' . $groupby;
    513513                }
    514                 $query = "SELECT $fields FROM $wpdb->comments $join WHERE $where $groupby ORDER BY $orderby $order $limits";
     514                if ( $orderby ) {
     515                        $orderby = 'ORDER BY ' . $orderby;
     516                }
     517                $query = "SELECT $fields FROM $wpdb->comments $join WHERE $where $groupby $orderby $order $limits";
    515518
    516519                if ( $this->query_vars['count'] ) {
    517520                        return $wpdb->get_var( $query );