Remove redundant table alias check in WP_Meta_Query.

Also adds documentation for 'meta_query_find_compatible_table_alias' filter.

See #24093.
Built from https://develop.svn.wordpress.org/trunk@29953


git-svn-id: http://core.svn.wordpress.org/trunk@29701 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Boone Gorges 2014-10-18 02:22:19 +00:00
parent 1804918131
commit 09e1239ad6
2 changed files with 14 additions and 10 deletions

View File

@ -1331,19 +1331,13 @@ class WP_Meta_Query {
$join .= " LEFT JOIN $this->meta_table";
$join .= $i ? " AS $alias" : '';
$join .= $wpdb->prepare( " ON ($this->primary_table.$this->primary_id_column = $alias.$this->meta_id_column AND $alias.meta_key = %s )", $clause['key'] );
$sql_chunks['join'][] = $join;
// All other JOIN clauses.
} else {
$alias = $this->find_compatible_table_alias( $clause, $parent_query );
if ( false === $alias ) {
$alias = $i ? 'mt' . $i : $this->meta_table;
$join .= " INNER JOIN $this->meta_table";
$join .= $i ? " AS $alias" : '';
$join .= " ON ( $this->primary_table.$this->primary_id_column = $alias.$this->meta_id_column )";
}
}
$this->table_aliases[] = $alias;
$sql_chunks['join'][] = $join;
@ -1469,6 +1463,16 @@ class WP_Meta_Query {
}
}
/**
* Filter the table alias identified as compatible with the current clause.
*
* @since 4.1.0
*
* @param string|bool $alias Table alias, or false if none was found.
* @param array $clause First-order query clause.
* @param array $parent_query Parent of $clause.
* @param object $this WP_Meta_Query object.
*/
return apply_filters( 'meta_query_find_compatible_table_alias', $alias, $clause, $parent_query, $this ) ;
}
}

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.1-alpha-20141017';
$wp_version = '4.1-alpha-20141018';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.