Strip redundant 'meta_' from 'meta_query' keys. See #14645
git-svn-id: http://svn.automattic.com/wordpress/trunk@15714 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
6107efe572
commit
1190c4094b
|
@ -4278,9 +4278,9 @@ function _wp_meta_sql( $queries, $primary_table, $primary_id_column, $meta_table
|
|||
$where = '';
|
||||
$i = 0;
|
||||
foreach ( $queries as $q ) {
|
||||
$meta_key = isset( $q['meta_key'] ) ? trim( $q['meta_key'] ) : '';
|
||||
$meta_value = isset( $q['meta_value'] ) ? trim( $q['meta_value'] ) : '';
|
||||
$meta_compare = isset( $q['meta_compare'] ) ? $q['meta_compare'] : '=';
|
||||
$meta_key = isset( $q['key'] ) ? trim( $q['key'] ) : '';
|
||||
$meta_value = isset( $q['value'] ) ? trim( $q['value'] ) : '';
|
||||
$meta_compare = isset( $q['compare'] ) ? $q['compare'] : '=';
|
||||
|
||||
if ( !in_array( $meta_compare, array( '=', '!=', '>', '>=', '<', '<=', 'like' ) ) )
|
||||
$meta_compare = '=';
|
||||
|
|
|
@ -1393,10 +1393,15 @@ class WP_Query {
|
|||
$this->meta_query = $qv['meta_query'];
|
||||
}
|
||||
|
||||
$meta_query = wp_array_slice_assoc( $qv, array( 'meta_key', 'meta_value', 'meta_compare' ) );
|
||||
$meta_query = array();
|
||||
foreach ( array( 'key', 'value', 'compare' ) as $key ) {
|
||||
if ( !empty( $qv[ "meta_$key" ] ) )
|
||||
$meta_query[ $key ] = $qv[ "meta_$key" ];
|
||||
}
|
||||
|
||||
if ( !empty( $meta_query ) )
|
||||
if ( !empty( $meta_query ) ) {
|
||||
$this->meta_query[] = $meta_query;
|
||||
}
|
||||
|
||||
if ( empty($qv['author']) || ($qv['author'] == '0') ) {
|
||||
$this->is_author = false;
|
||||
|
|
|
@ -451,17 +451,25 @@ class WP_User_Query {
|
|||
|
||||
if ( $blog_id ) {
|
||||
$cap_meta_query = array();
|
||||
$cap_meta_query['meta_key'] = $wpdb->get_blog_prefix( $blog_id ) . 'capabilities';
|
||||
$cap_meta_query['key'] = $wpdb->get_blog_prefix( $blog_id ) . 'capabilities';
|
||||
|
||||
if ( $role ) {
|
||||
$cap_meta_query['meta_value'] = $role;
|
||||
$cap_meta_query['meta_compare'] = 'like';
|
||||
$cap_meta_query['value'] = $role;
|
||||
$cap_meta_query['compare'] = 'like';
|
||||
}
|
||||
|
||||
$meta_queries[] = $cap_meta_query;
|
||||
}
|
||||
|
||||
$meta_queries[] = wp_array_slice_assoc( $qv, array( 'meta_key', 'meta_value', 'meta_compare' ) );
|
||||
$meta_query = array();
|
||||
foreach ( array( 'key', 'value', 'compare' ) as $key ) {
|
||||
if ( !empty( $qv[ "meta_$key" ] ) )
|
||||
$meta_query[ $key ] = $qv[ "meta_$key" ];
|
||||
}
|
||||
|
||||
if ( !empty( $meta_query ) ) {
|
||||
$meta_queries[] = $meta_query;
|
||||
}
|
||||
|
||||
list( $meta_join, $meta_where ) = _wp_meta_sql( $meta_queries, $wpdb->users, 'ID', $wpdb->usermeta, 'user_id' );
|
||||
$this->query_from .= $meta_join;
|
||||
|
|
Loading…
Reference in New Issue