Add context to get_meta_sql(). See #15018

git-svn-id: http://svn.automattic.com/wordpress/trunk@16286 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
scribu 2010-11-11 10:06:05 +00:00
parent cab19ed4aa
commit 8885e4f78e
3 changed files with 5 additions and 4 deletions

View File

@ -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 ) );
}
/**

View File

@ -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'];
}

View File

@ -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'];
}