Paginator maxLimit clamping behavior when clients request oversized page sizes
0 reputation · 08 Jun 2022, 20:36 UTC
I'm designing an API-style index endpoint on CakePHP that exposes pagination to clients through query string parameters, using the Paginator component's limit and maxLimit settings. The goal is to let clients pick a page size up to a hard ceiling, while guaranteeing that a crafted request with a very large limit value cannot force an unbounded result set.
My understanding is that limit sets the default page size and maxLimit caps what a client can request, with values above the cap being clamped rather than honored. What I'm unsure about is the exact fallback when maxLimit is not configured at all: I believe there is a framework default cap (historically 100), but I have not confirmed whether that default still applies in current 4.x/5.x releases or whether omitting it changes the clamping behavior.
I'm also unclear how per-call options passed to paginate() interact with the controller-level $paginate property when only one of them defines maxLimit.
Specifically: (1) Is the clamping silent, or is there any signal in the paging metadata that the requested limit was reduced? (2) What is the documented default cap when maxLimit is unset in CakePHP 5.x? (3) Do per-call options fully replace the controller defaults for pagination, or are they merged key by key?