aboutsummaryrefslogtreecommitdiffstats
path: root/core/include/search
diff options
context:
space:
mode:
authorThomas Lange <code@nerdmind.de>2021-07-22 21:17:57 +0200
committerThomas Lange <code@nerdmind.de>2021-07-22 21:17:57 +0200
commit0db1beaea6b849790aa0f1f4ecbf6439ce4f1104 (patch)
treee4fb555253891bbf8b192cd7ab5fd28cd7ef914c /core/include/search
parentcb9097e0199cf6afca3f144edb7d7addaec1cb59 (diff)
downloadblog-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/search')
-rw-r--r--core/include/search/main.php8
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();
}
}