Fixed invalid SQL in some circumstances
This commit is contained in:
parent
b1fb329fc7
commit
4a9cc4b3bc
2 changed files with 13 additions and 6 deletions
|
@ -11,9 +11,10 @@ class PostSearchService extends AbstractSearchService
|
|||
protected static function filterUserSafety(SqlQuery $sqlQuery)
|
||||
{
|
||||
$allowedSafety = PrivilegesHelper::getAllowedSafety();
|
||||
$sqlQuery->raw('safety')->in()->genSlots($allowedSafety);
|
||||
foreach ($allowedSafety as $s)
|
||||
$sqlQuery->put($s);
|
||||
if (empty($allowedSafety))
|
||||
$sqlQuery->raw('0');
|
||||
else
|
||||
$sqlQuery->raw('safety')->in()->genSlots($allowedSafety)->put($allowedSafety);
|
||||
}
|
||||
|
||||
protected static function filterUserHidden(SqlQuery $sqlQuery)
|
||||
|
@ -55,6 +56,9 @@ class PostSearchService extends AbstractSearchService
|
|||
{
|
||||
$ids = preg_split('/[;,]/', $val);
|
||||
$ids = array_map('intval', $ids);
|
||||
if (empty($ids))
|
||||
$sqlQuery->raw('0');
|
||||
else
|
||||
$sqlQuery->raw('id')->in()->genSlots($ids)->put($ids);
|
||||
}
|
||||
|
||||
|
|
|
@ -12,8 +12,11 @@ class TagSearchService extends AbstractSearchService
|
|||
->innerJoin('post_tag')
|
||||
->on('tag.id = post_tag.tag_id')
|
||||
->innerJoin('post')
|
||||
->on('post.id = post_tag.post_id')
|
||||
->where('safety')->in()->genSlots($allowedSafety);
|
||||
->on('post.id = post_tag.post_id');
|
||||
if (empty($allowedSafety))
|
||||
$sqlQuery->where('0');
|
||||
else
|
||||
$sqlQuery->where('safety')->in()->genSlots($allowedSafety);
|
||||
foreach ($allowedSafety as $s)
|
||||
$sqlQuery->put($s);
|
||||
|
||||
|
|
Loading…
Reference in a new issue