Ensure that 'who' param is respected when generating meta_query in `WP_User_Query`.

Since [31669], the 'who' param had been parsed after meta_query was generated,
so that 'who' was effectively ignored.

Props imath.
Fixes #32019.
Built from https://develop.svn.wordpress.org/trunk@32207


git-svn-id: http://core.svn.wordpress.org/trunk@32180 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Boone Gorges 2015-04-20 15:16:27 +00:00
parent 0dad375ece
commit bbc5a2de2f
2 changed files with 12 additions and 12 deletions

View File

@ -626,15 +626,22 @@ class WP_User_Query {
$include = false;
}
// Meta query.
$this->meta_query = new WP_Meta_Query();
$this->meta_query->parse_query_vars( $qv );
$blog_id = 0;
if ( isset( $qv['blog_id'] ) ) {
$blog_id = absint( $qv['blog_id'] );
}
if ( isset( $qv['who'] ) && 'authors' == $qv['who'] && $blog_id ) {
$qv['meta_key'] = $wpdb->get_blog_prefix( $blog_id ) . 'user_level';
$qv['meta_value'] = 0;
$qv['meta_compare'] = '!=';
$qv['blog_id'] = $blog_id = 0; // Prevent extra meta query
}
// Meta query.
$this->meta_query = new WP_Meta_Query();
$this->meta_query->parse_query_vars( $qv );
$role = '';
if ( isset( $qv['role'] ) ) {
$role = trim( $qv['role'] );
@ -775,13 +782,6 @@ class WP_User_Query {
$this->query_where .= $this->get_search_sql( $search, $search_columns, $wild );
}
if ( isset( $qv['who'] ) && 'authors' == $qv['who'] && $blog_id ) {
$qv['meta_key'] = $wpdb->get_blog_prefix( $blog_id ) . 'user_level';
$qv['meta_value'] = 0;
$qv['meta_compare'] = '!=';
$qv['blog_id'] = $blog_id = 0; // Prevent extra meta query
}
if ( ! empty( $include ) ) {
// Sanitized earlier.
$ids = implode( ',', $include );

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.2-RC1-32178';
$wp_version = '4.2-RC1-32207';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.