Skip to content

Commit

Permalink
Merge pull request #11662 from nanaya/clamp-null
Browse files Browse the repository at this point in the history
Fix parsing page parameter of ranking page
  • Loading branch information
notbakaneko authored Nov 16, 2024
2 parents 681f50a + 6cb743c commit 0a7736c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/Http/Controllers/RankingController.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,8 @@ public function index($mode, $type)

$maxResults = $this->maxResults($modeInt, $stats);
$maxPages = ceil($maxResults / static::PAGE_SIZE);
// TODO: less repeatedly getting params out of request.
$page = \Number::clamp(get_int(request('cursor.page') ?? request('page') ?? 1), 1, $maxPages);
$params = get_params(\Request::all(), null, ['cursor.page:int', 'page']);
$page = \Number::clamp($params['cursor']['page'] ?? $params['page'] ?? 1, 1, $maxPages);

$stats = $stats->limit(static::PAGE_SIZE)
->offset(static::PAGE_SIZE * ($page - 1))
Expand Down

0 comments on commit 0a7736c

Please sign in to comment.