Remove invalid `continue` calls from WP_Tax_Query::get_sql_for_clause().

This was leftover code from the previous implementation, which used a `foreach()`
loop. See [29901].

Props nofearinc.
See #29738, #29718.

git-svn-id: https://develop.svn.wordpress.org/trunk@29931 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Boone Gorges 2014-10-16 22:06:46 +00:00
parent 136436e9f1
commit 44bb383371
2 changed files with 55 additions and 2 deletions

View File

@ -1041,7 +1041,7 @@ class WP_Tax_Query {
} elseif ( 'NOT IN' == $operator ) { } elseif ( 'NOT IN' == $operator ) {
if ( empty( $terms ) ) { if ( empty( $terms ) ) {
continue; return $sql;
} }
$terms = implode( ',', $terms ); $terms = implode( ',', $terms );
@ -1055,7 +1055,7 @@ class WP_Tax_Query {
} elseif ( 'AND' == $operator ) { } elseif ( 'AND' == $operator ) {
if ( empty( $terms ) ) { if ( empty( $terms ) ) {
continue; return $sql;
} }
$num_terms = count( $terms ); $num_terms = count( $terms );

View File

@ -352,4 +352,57 @@ class Tests_Tax_Query extends WP_UnitTestCase {
_unregister_taxonomy( 'wptests_tax' ); _unregister_taxonomy( 'wptests_tax' );
} }
/**
* @ticket 29738
*/
public function test_get_sql_operator_not_in_empty_terms() {
register_taxonomy( 'wptests_tax', 'post' );
$tq = new WP_Tax_Query( array(
'relation' => 'OR',
array(
'taxonomy' => 'wptests_tax',
'field' => 'term_id',
'operator' => 'NOT IN',
'terms' => array(),
),
) );
global $wpdb;
$expected = array(
'join' => '',
'where' => '',
);
$this->assertSame( $expected, $tq->get_sql( $wpdb->posts, 'ID' ) );
_unregister_taxonomy( 'wptests_tax' );
}
/**
* @ticket 29738
*/
public function test_get_sql_operator_and_empty_terms() {
register_taxonomy( 'wptests_tax', 'post' );
$tq = new WP_Tax_Query( array(
'relation' => 'OR',
array(
'taxonomy' => 'wptests_tax',
'field' => 'term_id',
'operator' => 'AND',
'terms' => array(),
),
) );
global $wpdb;
$expected = array(
'join' => '',
'where' => '',
);
$this->assertSame( $expected, $tq->get_sql( $wpdb->posts, 'ID' ) );
_unregister_taxonomy( 'wptests_tax' );
}
} }