From 3cc827ef5a24c00d3f2ef33298b2cd6796c1bc36 Mon Sep 17 00:00:00 2001 From: Boone Gorges Date: Thu, 8 Oct 2015 21:05:50 +0000 Subject: [PATCH] Store SQL query string as a property on `WP_User_Query`. In addition to better parity with other WP query classes, this also allows testing of SQL strings, should anyone want to do something so foolish. See #22212. git-svn-id: https://develop.svn.wordpress.org/trunk@34956 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/class-wp-user-query.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/wp-includes/class-wp-user-query.php b/src/wp-includes/class-wp-user-query.php index 1bc08aa491..8f06450d55 100644 --- a/src/wp-includes/class-wp-user-query.php +++ b/src/wp-includes/class-wp-user-query.php @@ -52,6 +52,15 @@ class WP_User_Query { */ public $meta_query = false; + /** + * The SQL query used to fetch matching users. + * + * @since 4.4.0 + * @access public + * @var string + */ + public $request; + private $compat_fields = array( 'results', 'total_users' ); // SQL clauses @@ -442,12 +451,12 @@ class WP_User_Query { $qv =& $this->query_vars; - $query = "SELECT $this->query_fields $this->query_from $this->query_where $this->query_orderby $this->query_limit"; + $this->request = "SELECT $this->query_fields $this->query_from $this->query_where $this->query_orderby $this->query_limit"; if ( is_array( $qv['fields'] ) || 'all' == $qv['fields'] ) { - $this->results = $wpdb->get_results( $query ); + $this->results = $wpdb->get_results( $this->request ); } else { - $this->results = $wpdb->get_col( $query ); + $this->results = $wpdb->get_col( $this->request ); } /**