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.
Built from https://develop.svn.wordpress.org/trunk@34956


git-svn-id: http://core.svn.wordpress.org/trunk@34921 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Boone Gorges 2015-10-08 21:06:23 +00:00
parent 0b13fdf2fc
commit 99421d1799
2 changed files with 13 additions and 4 deletions

View File

@ -52,6 +52,15 @@ class WP_User_Query {
*/ */
public $meta_query = false; 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' ); private $compat_fields = array( 'results', 'total_users' );
// SQL clauses // SQL clauses
@ -442,12 +451,12 @@ class WP_User_Query {
$qv =& $this->query_vars; $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'] ) { if ( is_array( $qv['fields'] ) || 'all' == $qv['fields'] ) {
$this->results = $wpdb->get_results( $query ); $this->results = $wpdb->get_results( $this->request );
} else { } else {
$this->results = $wpdb->get_col( $query ); $this->results = $wpdb->get_col( $this->request );
} }
/** /**

View File

@ -4,7 +4,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '4.4-alpha-34955'; $wp_version = '4.4-alpha-34956';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.