From f780d0d09bfcff3a4dba3a8f2356a9e038ff31c8 Mon Sep 17 00:00:00 2001 From: Boone Gorges Date: Fri, 24 Oct 2014 02:34:18 +0000 Subject: [PATCH] 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. Built from https://develop.svn.wordpress.org/trunk@30003 git-svn-id: http://core.svn.wordpress.org/trunk@30003 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/comment.php | 18 ++++++++++++++---- wp-includes/version.php | 2 +- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/wp-includes/comment.php b/wp-includes/comment.php index f3746750a2..20b208ed9e 100644 --- a/wp-includes/comment.php +++ b/wp-includes/comment.php @@ -221,6 +221,15 @@ function get_comments( $args = '' ) { * @since 3.1.0 */ class WP_Comment_Query { + /** + * SQL for database query. + * + * @since 4.0.1 + * @access public + * @var string + */ + public $request; + /** * Metadata query container * @@ -578,18 +587,19 @@ class WP_Comment_Query { if ( $groupby ) { $groupby = 'GROUP BY ' . $groupby; } - $query = "SELECT $fields FROM $wpdb->comments $join WHERE $where $groupby ORDER BY $orderby $order $limits"; + + $this->request = "SELECT $fields FROM $wpdb->comments $join WHERE $where $groupby $orderby $order $limits"; if ( $this->query_vars['count'] ) { - return $wpdb->get_var( $query ); + return $wpdb->get_var( $this->request ); } if ( 'ids' == $this->query_vars['fields'] ) { - $this->comments = $wpdb->get_col( $query ); + $this->comments = $wpdb->get_col( $this->request ); return array_map( 'intval', $this->comments ); } - $results = $wpdb->get_results( $query ); + $results = $wpdb->get_results( $this->request ); /** * Filter the comment query results. * diff --git a/wp-includes/version.php b/wp-includes/version.php index 6b9f175e00..75feb8dba7 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.1-alpha-30002'; +$wp_version = '4.1-alpha-30003'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.