Skip to content

Commit

Permalink
fix: Fixed AjaxNodesExplorerController search params strict typing.
Browse files Browse the repository at this point in the history
  • Loading branch information
ambroisemaupate committed Mar 23, 2023
1 parent 3dc2c27 commit fd38552
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions lib/Rozier/src/AjaxControllers/AjaxNodesExplorerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,14 +173,25 @@ protected function getSolrSearchResults(
): array {
$this->nodeSourceSearchHandler->boostByUpdateDate();
$currentPage = $request->get('page', 1);
$searchQuery = $request->get('search');

if (!\is_string($searchQuery)) {
throw new InvalidParameterException('Search query must be a string');
}
if (empty($searchQuery)) {
throw new InvalidParameterException('Search query cannot be empty');
}
if ($currentPage < 1) {
throw new InvalidParameterException('Current page must be greater than 0');
}

$results = $this->nodeSourceSearchHandler->search(
$request->get('search'),
$searchQuery,
$arrayFilter,
$this->getItemPerPage(),
true,
10000000,
$currentPage
(int) $currentPage
);
$pageCount = ceil($results->getResultCount() / $this->getItemPerPage());
$nodesArray = $this->normalizeNodes($results);
Expand Down

0 comments on commit fd38552

Please sign in to comment.