Make WordPress Core

Ticket #58368: wp-comment-query-get-comment-count-no-orderby.patch

File wp-comment-query-get-comment-count-no-orderby.patch, 644 bytes (added by Guss77, 3 years ago)

Workaround as a patch - I really think this should be accepted as is.

  • wp-includes/class-wp-comment-query.php

    diff -u a/wp-includes/class-wp-comment-query.php b/wp-includes/class-wp-comment-query.php
    a b  
    959959                $this->sql_clauses['select']  = "SELECT $found_rows $fields";
    960960                $this->sql_clauses['from']    = "FROM $wpdb->comments $join";
    961961                $this->sql_clauses['groupby'] = $groupby;
    962                 $this->sql_clauses['orderby'] = $orderby;
     962                if ( !$this->query_vars['count'] )
     963                        $this->sql_clauses['orderby'] = $orderby;
    963964                $this->sql_clauses['limits']  = $limits;
    964965
    965966                $this->request = "