From 0db1beaea6b849790aa0f1f4ecbf6439ce4f1104 Mon Sep 17 00:00:00 2001 From: Thomas Lange Date: Thu, 22 Jul 2021 21:17:57 +0200 Subject: Catch possible PDOException for search request Catch possible PDOException on search requests with queries like "*" and pass the exception message to the template for displaying. --- core/include/search/main.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'core/include/search') diff --git a/core/include/search/main.php b/core/include/search/main.php index 14c2ac9..9e7c0a7 100644 --- a/core/include/search/main.php +++ b/core/include/search/main.php @@ -27,8 +27,12 @@ if($search = HTTP::GET('q')) { 'year' => HTTP::GET('y') ]; - if(!$posts = $PostRepository->search($search, $filter, $site_size, $offset)) { - $message = $Language->text('search_no_results', escapeHTML($search)); + try { + if (!$posts = $PostRepository->search($search, $filter, $site_size, $offset)) { + $message = $Language->text('search_no_results', escapeHTML($search)); + } + } catch(PDOException $Exception) { + $message = $Exception->getMessage(); } } -- cgit v1.2.3