- Affected version
- 2.1.7
\XF\Pub\Controller\Search::actionSearch()
requires that a keyword or username is given.Changing this behaviour (for example to allow searching for threads by prefix only) requires a fair amount of code duplication.
If this part was changed from
PHP:
if ($query->getErrors())
{
return $this->error($query->getErrors());
}
if (!strlen($query->getKeywords()) && !$query->getUserIds())
{
return $this->error(\XF::phrase('please_specify_search_query_or_name_of_member'));
}
to smth. like
PHP:
if (!strlen($query->getKeywords()) && !$query->getUserIds())
{
$query->error('no_keyword_or_member', \XF::phrase('please_specify_search_query_or_name_of_member'));
}
if ($query->getErrors())
{
return $this->error($query->getErrors());
}
it would become a lot easier (and IMHO cleaner, might even make sense to move that check to
prepareSearchQuery()
).