[wp-trac] [WordPress Trac] #39717: Search_terms_count includes stopwords
WordPress Trac
noreply at wordpress.org
Fri Jan 27 06:17:50 UTC 2017
#39717: Search_terms_count includes stopwords
--------------------------+-----------------------------
Reporter: msaari | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Query | Version: trunk
Severity: normal | Keywords:
Focuses: |
--------------------------+-----------------------------
If a search includes stopwords, the "search_terms_count" parameter will
not match the number of search terms in "search_terms". If you search for
"call of the wild" in an English installation, you'll get:
{{{
[search_terms_count] => 4
[search_terms] => Array
(
[0] => call
[1] => wild
)
}}}
The correct result should be:
{{{
[search_terms_count] => 2
[search_terms] => Array
(
[0] => call
[1] => wild
)
}}}
A simple correction would be to move the line
{{{
$q['search_terms_count'] = count( $matches[0] );
$q['search_terms'] = $this->parse_search_terms( $matches[0] );
}}}
after the search term parsing and change it to this:
{{{
$q['search_terms'] = $this->parse_search_terms( $matches[0] );
$q['search_terms_count'] = count( $q["search_terms"] );
}}}
Now the search_terms_count is correct. As far as I can tell, this has no
adverse side effects.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/39717>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list