An empty taxonomy query should return no results rather than all posts. Props wonderboymusic. fixes #20604

git-svn-id: https://develop.svn.wordpress.org/trunk@22109 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren 2012-10-04 13:16:47 +00:00
parent 1b3f54d73d
commit ca14391917
1 changed files with 9 additions and 6 deletions

View File

@ -660,23 +660,26 @@ class WP_Tax_Query {
$join = ''; $join = '';
$where = array(); $where = array();
$i = 0; $i = 0;
$count = count( $this->queries );
foreach ( $this->queries as $query ) { foreach ( $this->queries as $index => $query ) {
$this->clean_query( $query ); $this->clean_query( $query );
if ( is_wp_error( $query ) ) { if ( is_wp_error( $query ) )
return self::$no_results; return self::$no_results;
}
extract( $query ); extract( $query );
if ( 'IN' == $operator ) { if ( 'IN' == $operator ) {
if ( empty( $terms ) ) { if ( empty( $terms ) ) {
if ( 'OR' == $this->relation ) if ( 'OR' == $this->relation ) {
if ( ( $index + 1 === $count ) && empty( $where ) )
return self::$no_results;
continue; continue;
else } else {
return self::$no_results; return self::$no_results;
}
} }
$terms = implode( ',', $terms ); $terms = implode( ',', $terms );
@ -720,7 +723,7 @@ class WP_Tax_Query {
$i++; $i++;
} }
if ( !empty( $where ) ) if ( ! empty( $where ) )
$where = ' AND ( ' . implode( " $this->relation ", $where ) . ' )'; $where = ' AND ( ' . implode( " $this->relation ", $where ) . ' )';
else else
$where = ''; $where = '';