Skip to content

[6.x] Fix nocache pagination when ignoring query strings - #15788

Merged
jasonvarga merged 2 commits into
statamic:6.xfrom
lazerg:fix/issue-15787-nocache-pagination
Nov 9, 2026
Merged

jasonvarga merged 2 commits into
statamic:6.xfrom
lazerg:fix/issue-15787-nocache-pagination

Conversation

@lazerg

@lazerg lazerg commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

With ignore_query_strings enabled, a paginated collection inside a nocache region always renders page 1, even when you're on ?page=2.

The nocache endpoint strips the query string so it can find the session the cached page was written under. But the session then reads the current page from that same stripped URL, so page is already gone by the time the paginator asks for it.

This PR fixes it by giving the session the URL the browser actually sent, and reading the page from that one. The session lookup still uses the stripped URL.

Fixes #15787

@mynetx

mynetx commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Nice fix. One thing I noticed: setPaginationUrl($request->input('url')) passes the raw URL, which skips the normalizeQueryString() the controller applies to $url. Since the resolver does a substring match on page=, that changes behaviour even with ignore_query_strings off: ?zpage=9&page=2 now resolves page 9 (was 2, because normalizing sorts the keys), and ?page=%32 resolves 0 (was 2, normalizing decodes it). Normalizing first and stripping the query afterwards avoids it:

// after the endsWith / normalizeQueryString blocks
$session->setPaginationUrl($url);

if (config('statamic.static_caching.ignore_query_strings', false)) {
    $url = explode('?', $url)[0];
}

@lazerg

lazerg commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author

Good catch, thanks. I now normalize the URL before setting the pagination URL and added tests for both cases in e1fe7f3.

@jasonvarga
jasonvarga merged commit 5635b82 into statamic:6.x Nov 9, 2026
61 checks passed
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.

Pagination inside nocache always returns page 1 when full static caching ignores query strings

3 participants