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:
parent
136436e9f1
commit
44bb383371
|
@ -1041,7 +1041,7 @@ class WP_Tax_Query {
|
|||
} elseif ( 'NOT IN' == $operator ) {
|
||||
|
||||
if ( empty( $terms ) ) {
|
||||
continue;
|
||||
return $sql;
|
||||
}
|
||||
|
||||
$terms = implode( ',', $terms );
|
||||
|
@ -1055,7 +1055,7 @@ class WP_Tax_Query {
|
|||
} elseif ( 'AND' == $operator ) {
|
||||
|
||||
if ( empty( $terms ) ) {
|
||||
continue;
|
||||
return $sql;
|
||||
}
|
||||
|
||||
$num_terms = count( $terms );
|
||||
|
|
|
@ -352,4 +352,57 @@ class Tests_Tax_Query extends WP_UnitTestCase {
|
|||
_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' );
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue