Support searching for '0' in WP_Query.

Props swissspidy.
See #31025.

git-svn-id: https://develop.svn.wordpress.org/trunk@36278 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Boone Gorges 2016-01-13 04:36:54 +00:00
parent bf2f6f8104
commit 0b564d48df
2 changed files with 23 additions and 1 deletions

View File

@ -2775,7 +2775,7 @@ class WP_Query {
}
// If a search pattern is specified, load the posts that match.
if ( ! empty( $q['s'] ) ) {
if ( strlen( $q['s'] ) ) {
$search = $this->parse_search( $q );
}

View File

@ -137,4 +137,26 @@ class Tests_Query_Search extends WP_UnitTestCase {
$this->assertNotRegExp( '|ORDER BY \(CASE[^\)]+\)|', $q->request );
}
/**
* @ticket 31025
*/
public function test_s_zero() {
$p1 = $this->factory->post->create( array(
'post_status' => 'publish',
'post_title' => '1',
) );
$p2 = $this->factory->post->create( array(
'post_status' => 'publish',
'post_title' => '0',
) );
$q = new WP_Query( array(
's' => '0',
'fields' => 'ids',
) );
$this->assertEqualSets( array( $p2 ), $q->posts );
}
}