From 8885e4f78e32c23ad32447aaa3843596ef40f15d Mon Sep 17 00:00:00 2001 From: scribu Date: Thu, 11 Nov 2010 10:06:05 +0000 Subject: [PATCH] Add context to get_meta_sql(). See #15018 git-svn-id: http://svn.automattic.com/wordpress/trunk@16286 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/meta.php | 5 +++-- wp-includes/query.php | 2 +- wp-includes/user.php | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/wp-includes/meta.php b/wp-includes/meta.php index 4e9123f58..c9f5cddbc 100644 --- a/wp-includes/meta.php +++ b/wp-includes/meta.php @@ -369,9 +369,10 @@ function update_meta_cache($meta_type, $object_ids) { * @param string $meta_type * @param string $primary_table * @param string $primary_id_column + * @param object $context (optional) The main query object * @return array( 'join' => $join_sql, 'where' => $where_sql ) */ -function get_meta_sql( $meta_query, $meta_type, $primary_table, $primary_id_column ) { +function get_meta_sql( $meta_query, $meta_type, $primary_table, $primary_id_column, $context = null ) { global $wpdb; if ( ! $meta_table = _get_meta_table( $meta_type ) ) @@ -440,7 +441,7 @@ function get_meta_sql( $meta_query, $meta_type, $primary_table, $primary_id_colu unset( $meta_compare_string ); } - return apply_filters( 'get_meta_sql', compact( 'join', 'where' ), $meta_query, $meta_type, $primary_table, $primary_id_column ); + return apply_filters_ref_array( 'get_meta_sql', array( compact( 'join', 'where' ), $meta_query, $meta_type, $primary_table, $primary_id_column, &$context ) ); } /** diff --git a/wp-includes/query.php b/wp-includes/query.php index 309697b15..e58b63434 100644 --- a/wp-includes/query.php +++ b/wp-includes/query.php @@ -2147,7 +2147,7 @@ class WP_Query extends WP_Object_Query { } if ( !empty( $q['meta_query'] ) ) { - $clauses = get_meta_sql( $q['meta_query'], 'post', $wpdb->posts, 'ID' ); + $clauses = call_user_func_array( 'get_meta_sql', array( $q['meta_query'], 'post', $wpdb->posts, 'ID', &$this) ); $join .= $clauses['join']; $where .= $clauses['where']; } diff --git a/wp-includes/user.php b/wp-includes/user.php index b4c50cd1b..fc6913ba4 100644 --- a/wp-includes/user.php +++ b/wp-includes/user.php @@ -481,7 +481,7 @@ class WP_User_Query extends WP_Object_Query { } if ( !empty( $qv['meta_query'] ) ) { - $clauses = get_meta_sql( $qv['meta_query'], 'user', $wpdb->users, 'ID' ); + $clauses = call_user_func_array( 'get_meta_sql', array( $qv['meta_query'], 'user', $wpdb->users, 'ID', &$this ) ); $this->query_from .= $clauses['join']; $this->query_where .= $clauses['where']; }