[COMPONENT][Search] Don't explode if provided an empty search query
This commit is contained in:
parent
a16d31b70e
commit
b0d5ce8aab
|
@ -50,6 +50,7 @@ class Search extends FeedController
|
|||
$actor = Common::actor();
|
||||
$language = !\is_null($actor) ? $actor->getTopLanguage()->getLocale() : null;
|
||||
$q = $this->string('q');
|
||||
if (!empty($q) && !empty($q = trim($q))) {
|
||||
[$note_criteria, $actor_criteria] = Parser::parse($q, $language);
|
||||
|
||||
$note_qb = DB::createQueryBuilder();
|
||||
|
@ -68,6 +69,7 @@ class Search extends FeedController
|
|||
$actor_qb->addCriteria($actor_criteria);
|
||||
$actors = $actor_qb->getQuery()->execute();
|
||||
}
|
||||
}
|
||||
|
||||
$search_builder_form = Form::create([
|
||||
['include_actors', CheckboxType::class, ['required' => false, 'data' => false, 'label' => _m('Include people/actors')]],
|
||||
|
@ -150,8 +152,8 @@ class Search extends FeedController
|
|||
'_template' => 'search/show.html.twig',
|
||||
'search_form' => Comp\Search::searchForm($request, query: $q, add_subscribe: true),
|
||||
'search_builder_form' => $search_builder_form->createView(),
|
||||
'notes' => $notes,
|
||||
'actors' => $actors,
|
||||
'notes' => $notes ?? [],
|
||||
'actors' => $actors ?? [],
|
||||
'page' => 1, // TODO paginate
|
||||
];
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user