diff options
author | Thomas Lange <code@nerdmind.de> | 2021-07-22 21:17:57 +0200 |
---|---|---|
committer | Thomas Lange <code@nerdmind.de> | 2021-07-22 21:17:57 +0200 |
commit | 0db1beaea6b849790aa0f1f4ecbf6439ce4f1104 (patch) | |
tree | e4fb555253891bbf8b192cd7ab5fd28cd7ef914c /core/include | |
parent | cb9097e0199cf6afca3f144edb7d7addaec1cb59 (diff) | |
download | blog-0db1beaea6b849790aa0f1f4ecbf6439ce4f1104.tar.gz blog-0db1beaea6b849790aa0f1f4ecbf6439ce4f1104.tar.xz blog-0db1beaea6b849790aa0f1f4ecbf6439ce4f1104.zip |
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.
Diffstat (limited to 'core/include')
-rw-r--r-- | core/include/search/main.php | 8 |
1 files changed, 6 insertions, 2 deletions
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(); } } |