From 7678e155d940dbc4af17047cdac3379e5c9ff857 Mon Sep 17 00:00:00 2001 From: Diogo Peralta Cordeiro Date: Mon, 21 Feb 2022 04:49:08 +0000 Subject: [PATCH] [COMPONENT][Search] Ensure title is set when saving as feed --- components/Search/Search.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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; } }