Catch rare exception when searching ebooks

This commit is contained in:
Alex Cabal 2024-11-28 12:10:53 -06:00
parent 3a3795bbbd
commit 347f166e8a

View file

@ -2008,6 +2008,7 @@ class Ebook{
$params[] = $query;
}
try{
$ebooksCount = Db::QueryInt('
SELECT count(distinct e.EbookId)
from Ebooks e
@ -2028,6 +2029,17 @@ class Ebook{
order by ' . $orderBy . '
limit ?
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];
}