Skip to content

Commit

Permalink
An empty taxonomy query should return no results rather than all post…
Browse files Browse the repository at this point in the history
…s. Props wonderboymusic. fixes #20604

git-svn-id: http://core.svn.wordpress.org/trunk@22109 1a063a9b-81f0-0310-95a4-ce76da25c4cd
  • Loading branch information
Ryan Boren committed Oct 4, 2012
1 parent 7a86de8 commit 3c2b9a6
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions wp-includes/taxonomy.php
Expand Up @@ -660,23 +660,26 @@ public function get_sql( $primary_table, $primary_id_column ) {
$join = '';
$where = array();
$i = 0;
$count = count( $this->queries );

foreach ( $this->queries as $query ) {
foreach ( $this->queries as $index => $query ) {
$this->clean_query( $query );

if ( is_wp_error( $query ) ) {
if ( is_wp_error( $query ) )
return self::$no_results;
}

extract( $query );

if ( 'IN' == $operator ) {

if ( empty( $terms ) ) {
if ( 'OR' == $this->relation )
if ( 'OR' == $this->relation ) {
if ( ( $index + 1 === $count ) && empty( $where ) )
return self::$no_results;
continue;
else
} else {
return self::$no_results;
}
}

$terms = implode( ',', $terms );
Expand Down Expand Up @@ -720,7 +723,7 @@ public function get_sql( $primary_table, $primary_id_column ) {
$i++;
}

if ( !empty( $where ) )
if ( ! empty( $where ) )
$where = ' AND ( ' . implode( " $this->relation ", $where ) . ' )';
else
$where = '';
Expand Down

0 comments on commit 3c2b9a6

Please sign in to comment.