If the user get the error: "You must include at least one positive keyword with 3 characters or more."
Then if the user enters another search text that is bigger and press search then the user get the same error and it shows the previous search text.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

yingtho’s picture

Title: Search uses the old search text after error in text » Search uses the old search text after error in search text
yingtho’s picture

See attached patch to fix it. It properly could be done more correctly but at the moment I can't see a better way.

yingtho’s picture

Status: Active » Needs review

Change status.

jdanthinne’s picture

Patch seems ok, but I'd like to find where does this bug comes from at the first place… Are you using the default search block, or a custom block?

yingtho’s picture

I'm using the default custom search block from custom search block module. (I have only one block)

markgifford’s picture

Just chiming in to say I can't reproduce this error with a custom search block - Custom Search 1.16, core 7.27.

When I type two characters in the search field, hit enter and I get the "You must include at least one positive keyword with 3 characters or more" message. Add a couple of characters so the search term is at least 3, hit enter, and I just get no results, no warning message as expected.

yingtho’s picture

Do you have translation enabled and multilingual content when you test?

markgifford’s picture

@yingtho: no, neither

rebecca904’s picture

This patch works well for me to clear the error message of the keyword limits. Thanks, yingtho.
The search form on the result page is the default search not the custom search, if you enter more than 3 characters, it will get no warning message. But if you write a new custom search form on the result page by yourself, it will need you to clear the error message first and then to work.

rebecca904’s picture

The $language in the patch is not enough, it only gets the current language. We should consider if "current language and language neutral" is selected in "Search content from".

I changed as below:

// Add language if custom search i18n is included.
if (module_exists('custom_search_i18n'))
{
$i18n_search_language = variable_get('custom_search_i18n_search_language', 'all');
if ($i18n_search_language == 'current') {
$keys = search_expression_insert($keys, 'language', i18n_language()->language);
}
elseif ($i18n_search_language == 'current_neutral') {
$keys = search_expression_insert($keys, 'language', i18n_language()->language . ',und');
}
$q[count($q) - 1] .= $keys;
}

Munavijayalakshmi’s picture

Assigned: Unassigned » Munavijayalakshmi
Status: Needs review » Reviewed & tested by the community
FileSize
5.62 KB

Error in the posted image is not coming after applying the patch. Patch is working fine, moving to RTBC.

Munavijayalakshmi’s picture

Assigned: Munavijayalakshmi » Unassigned