mirror of
https://github.com/standardebooks/web.git
synced 2025-07-08 07:40:39 -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,26 +2008,38 @@ class Ebook{
|
|||
$params[] = $query;
|
||||
}
|
||||
|
||||
$ebooksCount = Db::QueryInt('
|
||||
SELECT count(distinct e.EbookId)
|
||||
from Ebooks e
|
||||
' . $joinContributors . '
|
||||
' . $joinTags . '
|
||||
' . $whereCondition . '
|
||||
', $params);
|
||||
try{
|
||||
$ebooksCount = Db::QueryInt('
|
||||
SELECT count(distinct e.EbookId)
|
||||
from Ebooks e
|
||||
' . $joinContributors . '
|
||||
' . $joinTags . '
|
||||
' . $whereCondition . '
|
||||
', $params);
|
||||
|
||||
$params[] = $limit;
|
||||
$params[] = $offset;
|
||||
$params[] = $limit;
|
||||
$params[] = $offset;
|
||||
|
||||
$ebooks = Db::Query('
|
||||
SELECT distinct e.*
|
||||
from Ebooks e
|
||||
' . $joinContributors . '
|
||||
' . $joinTags . '
|
||||
' . $whereCondition . '
|
||||
order by ' . $orderBy . '
|
||||
limit ?
|
||||
offset ?', $params, Ebook::class);
|
||||
$ebooks = Db::Query('
|
||||
SELECT distinct e.*
|
||||
from Ebooks e
|
||||
' . $joinContributors . '
|
||||
' . $joinTags . '
|
||||
' . $whereCondition . '
|
||||
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];
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue