diff --git a/components/Search/Search.php b/components/Search/Search.php index e595387b0f..fe14441fd1 100644 --- a/components/Search/Search.php +++ b/components/Search/Search.php @@ -25,6 +25,7 @@ namespace Component\Search; use App\Core\Event; use App\Core\Form; +use App\Util\Exception\ClientException; use function App\Core\I18n\_m; use App\Core\Modules\Component; use App\Util\Common; @@ -109,8 +110,11 @@ class Search extends Component /** @var SubmitButton $subscribe */ $subscribe = $form->get('subscribe_to_search'); if ($subscribe->isClicked()) { - // TODO ensure title is set - Event::handle('AppendFeed', [$actor, $data['title'], 'search', ['q' => $data['search_query']]]); + if (!\is_null($data['title'])) { + Event::handle('AppendFeed', [$actor, $data['title'], 'search', ['q' => $data['search_query']]]); + } else { + throw new ClientException(_m('Empty title is not allowed.')); + } $redirect = true; } }