If the queried term does not exist make sure no posts are returned in the query rather than falling through to querying all posts. Fixes 404s when querying cats that do not exist. see #12891

git-svn-id: http://svn.automattic.com/wordpress/trunk@16511 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2010-11-20 21:10:20 +00:00
parent d29759048d
commit 44733f9635
2 changed files with 8 additions and 3 deletions

View File

@ -1947,8 +1947,12 @@ class WP_Query {
if ( !empty( $this->tax_query ) ) {
$clauses = call_user_func_array( 'get_tax_sql', array( $this->tax_query, $wpdb->posts, 'ID', &$this) );
$join .= $clauses['join'];
$where .= $clauses['where'];
if ( empty($clauses['join']) && empty($clauses['where']) ) {
$where .= ' AND 0 = 1';
} else {
$join .= $clauses['join'];
$where .= $clauses['where'];
}
if ( $this->is_tax ) {
if ( empty($post_type) ) {

View File

@ -539,7 +539,7 @@ function get_tax_sql( $tax_query, $primary_table, $primary_id_column ) {
foreach ( $taxonomies as $taxonomy ) {
if ( ! taxonomy_exists( $taxonomy ) )
return ' AND 0 = 1';
return array( 'join' => '', 'where' => ' AND 0 = 1');
}
$taxonomies = "'" . implode( "', '", $taxonomies ) . "'";
@ -592,6 +592,7 @@ function get_tax_sql( $tax_query, $primary_table, $primary_id_column ) {
)";
}
}
return compact( 'join', 'where' );
}