Improve WP_Tax_Query param sanitization for empty strings.

When an empty string is passed as one of the clauses in the `$tax_query`
parameter, it should be discarded rather than parsed as a first-order clause.

Props tmtrademark.
Fixes #30117.

git-svn-id: https://develop.svn.wordpress.org/trunk@30031 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Boone Gorges
2014-10-26 22:56:36 +00:00
parent b92307f58d
commit ae0ae95be6
2 changed files with 16 additions and 1 deletions
+15
View File
@@ -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(),