diff --git a/src/wp-includes/taxonomy.php b/src/wp-includes/taxonomy.php index 2eecfecf7c..b8261dfeec 100644 --- a/src/wp-includes/taxonomy.php +++ b/src/wp-includes/taxonomy.php @@ -832,7 +832,7 @@ class WP_Tax_Query { * @return bool Whether the query clause is a first-order clause. */ protected static function is_first_order_clause( $query ) { - return empty( $query ) || array_key_exists( 'terms', $query ) || array_key_exists( 'taxonomy', $query ) || array_key_exists( 'include_children', $query ) || array_key_exists( 'field', $query ) || array_key_exists( 'operator', $query ); + return is_array( $query ) && ( empty( $query ) || array_key_exists( 'terms', $query ) || array_key_exists( 'taxonomy', $query ) || array_key_exists( 'include_children', $query ) || array_key_exists( 'field', $query ) || array_key_exists( 'operator', $query ) ); } /** diff --git a/tests/phpunit/tests/term/query.php b/tests/phpunit/tests/term/query.php index 57dac3610c..17786fea7c 100644 --- a/tests/phpunit/tests/term/query.php +++ b/tests/phpunit/tests/term/query.php @@ -85,6 +85,21 @@ class Tests_Tax_Query extends WP_UnitTestCase { $this->assertEquals( array( 'foo', ), $tq->queries[0]['terms'] ); } + /** + * @ticket 30117 + */ + public function test_construct_empty_strings_array_members_should_be_discarded() { + $q = new WP_Tax_Query( array( + '', + array( + 'taxonomy' => 'post_tag', + 'terms' => 'foo', + ), + ) ); + + $this->assertSame( 1, count( $q->queries ) ); + } + public function test_transform_query_terms_empty() { $tq = new WP_Tax_Query( array( array(),