Just pass meta type to get_meta_sql(). See #15032
git-svn-id: http://svn.automattic.com/wordpress/trunk@16143 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
b29899f93f
commit
d2e8b78a42
|
@ -87,15 +87,19 @@ class WP_Object_Query {
|
|||
* Possible values: 'NUMERIC', 'BINARY', 'CHAR', 'DATE', 'DATETIME', 'DECIMAL', 'SIGNED', 'TIME', 'UNSIGNED'.
|
||||
* Default: 'CHAR'
|
||||
*
|
||||
* @param string $meta_type
|
||||
* @param string $primary_table
|
||||
* @param string $primary_id_column
|
||||
* @param string $meta_table
|
||||
* @param string $meta_id_column
|
||||
* @return array( $join_sql, $where_sql )
|
||||
*/
|
||||
function get_meta_sql( $meta_query, $primary_table, $primary_id_column, $meta_table, $meta_id_column ) {
|
||||
function get_meta_sql( $meta_query, $meta_type, $primary_table, $primary_id_column ) {
|
||||
global $wpdb;
|
||||
|
||||
if ( ! $meta_table = _get_meta_table( $meta_type ) )
|
||||
return false;
|
||||
|
||||
$meta_id_column = esc_sql( $meta_type . '_id' );
|
||||
|
||||
$clauses = array();
|
||||
|
||||
$join = '';
|
||||
|
@ -157,7 +161,7 @@ class WP_Object_Query {
|
|||
unset( $meta_compare_string );
|
||||
}
|
||||
|
||||
return apply_filters( 'get_meta_sql', compact( 'join', 'where' ), $meta_query, $primary_table, $primary_id_column, $meta_table, $meta_id_column );
|
||||
return apply_filters( 'get_meta_sql', compact( 'join', 'where' ), $meta_query, $meta_type, $primary_table, $primary_id_column );
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -2146,7 +2146,7 @@ class WP_Query extends WP_Object_Query {
|
|||
}
|
||||
|
||||
if ( !empty( $q['meta_query'] ) ) {
|
||||
$clauses = $this->get_meta_sql( $q['meta_query'], $wpdb->posts, 'ID', $wpdb->postmeta, 'post_id' );
|
||||
$clauses = $this->get_meta_sql( $q['meta_query'], 'post', $wpdb->posts, 'ID' );
|
||||
$join .= $clauses['join'];
|
||||
$where .= $clauses['where'];
|
||||
}
|
||||
|
|
|
@ -468,7 +468,7 @@ class WP_User_Query extends WP_Object_Query {
|
|||
}
|
||||
|
||||
if ( !empty( $qv['meta_query'] ) ) {
|
||||
$clauses = $this->get_meta_sql( $qv['meta_query'], $wpdb->users, 'ID', $wpdb->usermeta, 'user_id' );
|
||||
$clauses = $this->get_meta_sql( $qv['meta_query'], 'user', $wpdb->users, 'ID' );
|
||||
$this->query_from .= $clauses['join'];
|
||||
$this->query_where .= $clauses['where'];
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue