Make WordPress Core


Ignore:
Timestamp:
10/24/2014 02:33:46 AM (11 years ago)
Author:
boonebgorges
Message:

Add unit tests for WP_Comment_Query 'orderby' param.

For better testability, the SQL string generated in WP_Comment_Query::get_posts()
is now stored as a 'request' property on the object.

See #29902.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/comment.php

    r29965 r30003  
    222222 */
    223223class WP_Comment_Query {
     224    /**
     225     * SQL for database query.
     226     *
     227     * @since 4.0.1
     228     * @access public
     229     * @var string
     230     */
     231    public $request;
     232
    224233    /**
    225234     * Metadata query container
     
    579588            $groupby = 'GROUP BY ' . $groupby;
    580589        }
    581         $query = "SELECT $fields FROM $wpdb->comments $join WHERE $where $groupby ORDER BY $orderby $order $limits";
     590
     591        $this->request = "SELECT $fields FROM $wpdb->comments $join WHERE $where $groupby $orderby $order $limits";
    582592
    583593        if ( $this->query_vars['count'] ) {
    584             return $wpdb->get_var( $query );
     594            return $wpdb->get_var( $this->request );
    585595        }
    586596
    587597        if ( 'ids' == $this->query_vars['fields'] ) {
    588             $this->comments = $wpdb->get_col( $query );
     598            $this->comments = $wpdb->get_col( $this->request );
    589599            return array_map( 'intval', $this->comments );
    590600        }
    591601
    592         $results = $wpdb->get_results( $query );
     602        $results = $wpdb->get_results( $this->request );
    593603        /**
    594604         * Filter the comment query results.
Note: See TracChangeset for help on using the changeset viewer.