diff --git src/wp-includes/query.php src/wp-includes/query.php
index 4b3e1e4..12debb7 100644
|
|
|
class WP_Query { |
| 2194 | 2194 | else |
| 2195 | 2195 | $term = trim( $term, "\"' " ); |
| 2196 | 2196 | |
| 2197 | | // Avoid single A-Z. |
| 2198 | | if ( ! $term || ( 1 === strlen( $term ) && preg_match( '/^[a-z]$/i', $term ) ) ) |
| | 2197 | // Avoid single A-Z and single dashes. |
| | 2198 | if ( ! $term || ( 1 === strlen( $term ) && preg_match( '/^[a-z]$/i', $term ) || '-' === $term ) ) |
| 2199 | 2199 | continue; |
| 2200 | 2200 | |
| 2201 | 2201 | if ( in_array( call_user_func( $strtolower, $term ), $stopwords, true ) ) |
diff --git tests/phpunit/tests/query/search.php tests/phpunit/tests/query/search.php
index 35f734b..7f7db19 100644
|
|
|
class Tests_Query_Search extends WP_UnitTestCase { |
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | /** |
| | 130 | * @ticket 36195 |
| | 131 | */ |
| | 132 | public function test_s_should_not_exclude_for_dashes_between_words() { |
| | 133 | $p1 = self::factory()->post->create( array( |
| | 134 | 'post_status' => 'publish', |
| | 135 | 'post_content' => 'This post has foo but also bar', |
| | 136 | ) ); |
| | 137 | $p2 = self::factory()->post->create( array( |
| | 138 | 'post_status' => 'publish', |
| | 139 | 'post_content' => 'This post has only bar', |
| | 140 | ) ); |
| | 141 | $p3 = self::factory()->post->create( array( |
| | 142 | 'post_status' => 'publish', |
| | 143 | 'post_content' => 'This post has only foo - bar', |
| | 144 | ) ); |
| | 145 | |
| | 146 | $q = new WP_Query( array( |
| | 147 | 's' => 'foo - bar', |
| | 148 | 'fields' => 'ids', |
| | 149 | ) ); |
| | 150 | |
| | 151 | $this->assertEqualSets( array( $p1, $p3 ), $q->posts ); |
| | 152 | } |
| | 153 | |
| | 154 | /** |
| 130 | 155 | * @ticket 35361 |
| 131 | 156 | */ |
| 132 | 157 | public function test_search_orderby_should_be_empty_when_search_string_is_longer_than_6_words_and_exclusion_operator_is_used() { |