Ticket #44296: 44296_1.patch
File 44296_1.patch, 1.7 KB (added by , 6 years ago) |
---|
-
src/wp-includes/class-wp-query.php
1308 1308 } 1309 1309 // there are no line breaks in <input /> fields 1310 1310 $q['s'] = str_replace( array( "\r", "\n" ), '', $q['s'] ); 1311 // replace double-width space to half-width. 1312 $q['s'] = mb_convert_kana($q['s'], 's'); 1311 1313 $q['search_terms_count'] = 1; 1312 1314 if ( ! empty( $q['sentence'] ) ) { 1313 1315 $q['search_terms'] = array( $q['s'] ); -
tests/phpunit/tests/query/search.php
60 60 $this->assertEquals( array( 'search', 'term' ), $query->get( 'search_terms' ) ); 61 61 } 62 62 63 /** 64 * Check if double-width space will be recognized as a separator 65 */ 66 function test_filter_stopwords_including_double_width_space() { 67 $terms = 'This is a search term'; 68 add_filter( 'wp_search_stopwords', array( $this, 'filter_wp_search_stopwords' ) ); 69 $query = new WP_Query( array( 's' => $terms ) ); 70 remove_filter( 'wp_search_stopwords', array( $this, 'filter_wp_search_stopwords' ) ); 71 72 $this->assertNotEquals( explode( ' ', $terms ), $query->get( 'search_terms' ) ); 73 $this->assertEquals( 5, $query->get( 'search_terms_count') ); 74 $this->assertEquals( array( 'This', 'is', 'search', 'term' ), $query->get( 'search_terms' ) ); 75 } 76 63 77 function test_filter_stopwords() { 64 78 $terms = 'This is a search term'; 65 79 add_filter( 'wp_search_stopwords', array( $this, 'filter_wp_search_stopwords' ) );