From 033dc3afa27d171879ca321f3f06f388745f092b Mon Sep 17 00:00:00 2001 From: scribu Date: Mon, 1 Nov 2010 20:34:54 +0000 Subject: [PATCH] Just pass meta type to get_meta_sql(). See #15032 git-svn-id: https://develop.svn.wordpress.org/trunk@16143 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/class-wp-object-query.php | 12 ++++++++---- wp-includes/query.php | 2 +- wp-includes/user.php | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/wp-includes/class-wp-object-query.php b/wp-includes/class-wp-object-query.php index 1f3907ba8e..fcb04b1e27 100644 --- a/wp-includes/class-wp-object-query.php +++ b/wp-includes/class-wp-object-query.php @@ -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 ); } /* diff --git a/wp-includes/query.php b/wp-includes/query.php index 9076d1953a..716b31d5d8 100644 --- a/wp-includes/query.php +++ b/wp-includes/query.php @@ -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']; } diff --git a/wp-includes/user.php b/wp-includes/user.php index 9e779fb789..2f9b31581a 100644 --- a/wp-includes/user.php +++ b/wp-includes/user.php @@ -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']; }