mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2025-10-16 12:05:38 +00:00
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:
parent
bf2f6f8104
commit
0b564d48df
@ -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 );
|
||||
}
|
||||
|
||||
|
||||
@ -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 );
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user