mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-07-01 15:50:09 +00:00
Query: Ignore search terms consisting of a single dash.
Due to the "exclude" support added in WP 4.4, single dashes were being converted to "NOT LIKE '%%'" clauses, causing all searches to fail. Props RomSocial, swissspidy. Fixes #36195. git-svn-id: https://develop.svn.wordpress.org/trunk@36989 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -126,6 +126,31 @@ class Tests_Query_Search extends WP_UnitTestCase {
|
||||
$this->assertEqualSets( array( $p3 ), $q->posts );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 36195
|
||||
*/
|
||||
public function test_s_should_not_exclude_for_dashes_between_words() {
|
||||
$p1 = self::factory()->post->create( array(
|
||||
'post_status' => 'publish',
|
||||
'post_content' => 'This post has foo but also bar',
|
||||
) );
|
||||
$p2 = self::factory()->post->create( array(
|
||||
'post_status' => 'publish',
|
||||
'post_content' => 'This post has only bar',
|
||||
) );
|
||||
$p3 = self::factory()->post->create( array(
|
||||
'post_status' => 'publish',
|
||||
'post_content' => 'This post has only foo - bar',
|
||||
) );
|
||||
|
||||
$q = new WP_Query( array(
|
||||
's' => 'foo - bar',
|
||||
'fields' => 'ids',
|
||||
) );
|
||||
|
||||
$this->assertEqualSets( array( $p1, $p3 ), $q->posts );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 35361
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user