mirror of
https://github.com/standardebooks/web.git
synced 2025-07-08 15:50:29 -04:00
Catch rare exception when searching ebooks
This commit is contained in:
parent
3a3795bbbd
commit
347f166e8a
1 changed files with 30 additions and 18 deletions
|
@ -2008,6 +2008,7 @@ class Ebook{
|
||||||
$params[] = $query;
|
$params[] = $query;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try{
|
||||||
$ebooksCount = Db::QueryInt('
|
$ebooksCount = Db::QueryInt('
|
||||||
SELECT count(distinct e.EbookId)
|
SELECT count(distinct e.EbookId)
|
||||||
from Ebooks e
|
from Ebooks e
|
||||||
|
@ -2028,6 +2029,17 @@ class Ebook{
|
||||||
order by ' . $orderBy . '
|
order by ' . $orderBy . '
|
||||||
limit ?
|
limit ?
|
||||||
offset ?', $params, Ebook::class);
|
offset ?', $params, Ebook::class);
|
||||||
|
}
|
||||||
|
catch(Exceptions\DatabaseQueryException $ex){
|
||||||
|
if(stripos($ex->getMessage(), 'General error: 191 Too many words in a FTS phrase or proximity search') !== false){
|
||||||
|
// This exception occurs when the search string is too long for MariaDB to handle.
|
||||||
|
$ebooksCount = 0;
|
||||||
|
$ebooks = [];
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
throw $ex;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return ['ebooks' => $ebooks, 'ebooksCount' => $ebooksCount];
|
return ['ebooks' => $ebooks, 'ebooksCount' => $ebooksCount];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue