Skip to content

[6.x] Cap CP perPage query parameter to configured ceiling#14668

Merged
jasonvarga merged 2 commits into
6.xfrom
cap-cp-per-page
May 13, 2026
Merged

[6.x] Cap CP perPage query parameter to configured ceiling#14668
jasonvarga merged 2 commits into
6.xfrom
cap-cp-per-page

Conversation

@jasonvarga
Copy link
Copy Markdown
Member

@jasonvarga jasonvarga commented May 13, 2026

CP listing endpoints currently read ?perPage= straight from the request and pass it to the paginator with no validation, so a request like ?perPage=999999 will materialize an arbitrary number of rows.

This PR clamps the effective perPage to max(config('statamic.cp.pagination_size_options')) at every CP read site, via a new Statamic::cpPerPage() helper. Values within range pass through unchanged; values above the ceiling are clamped down. The per-page dropdown's behaviour is unaffected.

Also drops 500 from the default pagination_size_options — both as an unreasonably large default page size and to lower the new ceiling. Existing installs will keep 500 since they'd already have it in their config/statamic/cp.php.

jasonvarga and others added 2 commits May 13, 2026 13:22
Clamp the requested `perPage` against `max(pagination_size_options)` at
every CP listing and relationship-fieldtype index endpoint so a request
like `?perPage=999999` can't force the server to materialize an
arbitrary number of rows.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
500 rows per page is unreasonably high as a default option and now also
acts as the upper bound for the `?perPage=` query parameter, so trim it
from the default list.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@jasonvarga jasonvarga merged commit 664fad7 into 6.x May 13, 2026
19 checks passed
@jasonvarga jasonvarga deleted the cap-cp-per-page branch May 13, 2026 17:58
duncanmcclean pushed a commit that referenced this pull request May 14, 2026
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant