Skip to content

Commit

Permalink
* fix converting the value of query param orderBy.direction from `s…
Browse files Browse the repository at this point in the history
…tring` to `bool` that forcing any direction get treated as `DESC` @ `App\PostsQuery\SearchQuery->query()`

* fix the fallback value of `$cursor` should be stringify integer to pass the following validating with `ctype_digit()` @ `App\Controller\SitemapController->forums()`
@ be
  • Loading branch information
n0099 committed Oct 14, 2024
1 parent 122379f commit fa89c03
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion be/src/Controller/SitemapController.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function (ItemInterface $item) use ($threadsIdKeyByFid) {
#[Route('/sitemaps/forums/{fid}/threads', requirements: ['fid' => /** @lang JSRegexp */'\d+'])]
public function threads(Request $request, Validator $validator, int $fid): Response
{
$cursor = $request->query->get('cursor') ?? 0;
$cursor = $request->query->get('cursor') ?? '0';
$validator->validate($cursor, new Assert\Type('digit'));
Helper::abortAPIIfNot(40406, $this->forumRepository->isForumExists($fid));

Expand Down
2 changes: 1 addition & 1 deletion be/src/PostsQuery/SearchQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function query(QueryParams $params, ?string $cursor): void

$orderByParam = $params->pick('orderBy')[0];
$this->setOrderByField($orderByParam->value === 'default' ? 'postedAt' : $orderByParam->value);
$this->setOrderByDesc($orderByParam->value === 'default' ? true : $orderByParam->getSub('direction'));
$this->setOrderByDesc($orderByParam->value === 'default' || $orderByParam->getSub('direction') === 'DESC');

/** @var array<string, array> $cachedUserQueryResult key by param name */
$cachedUserQueryResult = [];
Expand Down

0 comments on commit fa89c03

Please sign in to comment.