forked from leftypol/leftypol
SearchService.php: check for query too broad
This commit is contained in:
parent
b61cb8acf3
commit
a749cc829c
1 changed files with 13 additions and 2 deletions
|
|
@ -338,14 +338,25 @@ class SearchService {
|
|||
*
|
||||
* @param SearchFilters $filters An array of filters made by {@see self::parse()}.
|
||||
* @param ?string $fallback_board Fallback board if there isn't a board filter.
|
||||
* @return array Data array straight from the PDO, with all the fields in posts.sql
|
||||
* @return ?array Data array straight from the PDO, with all the fields in posts.sql, or null if the query was too broad.
|
||||
*/
|
||||
public function search(string $ip, string $raw_query, SearchFilters $filters, ?string $fallback_board): array {
|
||||
public function search(string $ip, string $raw_query, SearchFilters $filters, ?string $fallback_board): ?array {
|
||||
$board = !empty($filters->board) ? $filters->board : $fallback_board;
|
||||
if ($board === null) {
|
||||
return [];
|
||||
}
|
||||
|
||||
// Only board is specified.
|
||||
if (empty($filters->subject) &&
|
||||
empty($filters->name) &&
|
||||
empty($filters->flag) &&
|
||||
$filters->id === null &&
|
||||
$filters->thread === null &&
|
||||
empty($filters->body)
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!\in_array($board, $this->searchable_board_uris)) {
|
||||
return [];
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue