From 09e1239ad69d23c775a9a75d8f7fc4ba6e91052c Mon Sep 17 00:00:00 2001 From: Boone Gorges Date: Sat, 18 Oct 2014 02:22:19 +0000 Subject: [PATCH] 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 --- wp-includes/meta.php | 22 +++++++++++++--------- wp-includes/version.php | 2 +- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/wp-includes/meta.php b/wp-includes/meta.php index 767e09e625..e1d0652214 100644 --- a/wp-includes/meta.php +++ b/wp-includes/meta.php @@ -1331,18 +1331,12 @@ 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 )"; - } + $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; @@ -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 ) ; } } diff --git a/wp-includes/version.php b/wp-includes/version.php index b4389c245c..cb970f54a5 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -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.