diff --git src/wp-includes/query.php src/wp-includes/query.php
index 053f4e9..95b637c 100644
|
|
class WP_Query { |
2154 | 2154 | } |
2155 | 2155 | |
2156 | 2156 | $like = $n . $wpdb->esc_like( $term ) . $n; |
2157 | | $search .= $wpdb->prepare( "{$searchand}(($wpdb->posts.post_title $like_op %s) $andor_op ($wpdb->posts.post_content $like_op %s))", $like, $like ); |
| 2157 | $search .= $wpdb->prepare( "{$searchand}(($wpdb->posts.post_title $like_op %s) $andor_op ($wpdb->posts.post_content $like_op %s) $andor_op ($wpdb->posts.post_excerpt $like_op %s))", $like, $like, $like ); |
2158 | 2158 | $searchand = ' AND '; |
2159 | 2159 | } |
2160 | 2160 | |
diff --git tests/phpunit/tests/query/search.php tests/phpunit/tests/query/search.php
index 859cd98..4fb92f1 100644
|
|
class Tests_Query_Search extends WP_UnitTestCase { |
178 | 178 | $this->assertNotContains( 'posts_search', $q->request ); |
179 | 179 | } |
180 | 180 | |
| 181 | /** |
| 182 | * @ticket 35762 |
| 183 | */ |
| 184 | public function test_search_post_excerpt() { |
| 185 | $p1 = self::factory()->post->create( array( |
| 186 | 'post_status' => 'publish', |
| 187 | 'post_content' => 'This post has foo but also bar', |
| 188 | ) ); |
| 189 | $p2 = self::factory()->post->create( array( |
| 190 | 'post_status' => 'publish', |
| 191 | 'post_content' => '', |
| 192 | 'post_excerpt' => 'This post has only bar', |
| 193 | ) ); |
| 194 | $p3 = self::factory()->post->create( array( |
| 195 | 'post_status' => 'publish', |
| 196 | 'post_content' => '', |
| 197 | 'post_excerpt' => 'This post has only foo-bar', |
| 198 | ) ); |
| 199 | |
| 200 | $q = new WP_Query( array( |
| 201 | 's' => 'foo-bar', |
| 202 | 'fields' => 'ids', |
| 203 | ) ); |
| 204 | |
| 205 | $this->assertEqualSets( array( $p3 ), $q->posts ); |
| 206 | |
| 207 | $q = new WP_Query( array( |
| 208 | 's' => 'bar', |
| 209 | 'fields' => 'ids', |
| 210 | ) ); |
| 211 | |
| 212 | $this->assertEqualSets( array( $p1, $p2, $p3 ), $q->posts ); |
| 213 | } |
| 214 | |
181 | 215 | public function filter_posts_search( $sql ) { |
182 | 216 | return $sql . ' /* posts_search */'; |
183 | 217 | } |