Fix history page pagination off-by-one#12430
Merged
Merged
Conversation
…etarchive#12420) PR internetarchive#12169 migrated pagination to the ol-pagination web component, which uses 1-indexed URLs (page 1 = no ?page param, page 2 = ?page=2). The history handler was left on the old 0-indexed scheme (?page=0 = page 1, offset = 20 * page), and the template bridged them with a `+1` — but applied it when passing the page to the component rather than when interpreting the URL. So each click drifted further out of sync. Align the handler, the URL, and the template on 1-indexed pages to match every other paginated page on the site (admin/people/edits, loan_history, admin/memory). This fixes: - internetarchive#12398: Previous arrow on page 2 links back to page 2 - internetarchive#12420: History pages double-skip, making most revisions unreachable Also replaces the brittle `len(h) == 20` has-next check with a `limit + 1` fetch so the Next arrow no longer appears on exact-20-item last pages.
tfmorris
reviewed
Apr 22, 2026
Comment on lines
+205
to
+206
| # Clamp so legacy ?page=0 links resolve to the first page instead of a negative offset. | ||
| offset = limit * max(0, safeint(i.page) - 1) |
Contributor
There was a problem hiding this comment.
Why not fix the front end to maintain compatibility rather than making a breaking change to the backend?
Collaborator
Author
There was a problem hiding this comment.
The ol-pagination component is already powering admin/people/edits, loan_history, and admin/memory, all of which have been 1-indexed all along. History was the lone 0-indexed holdout. So it didn't seem to make sense to add permanent complexity to the front-end component to preserve a convention only one page used.
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This fixes:
Technical
PR #12169 migrated pagination to the ol-pagination web component, which uses 1-indexed URLs (page 1 = no ?page param, page 2 = ?page=2).
The history handler was left on the old 0-indexed scheme (?page=0 = page 1, offset = 20 * page), and the template bridged them with a
+1- but applied it when passing the page to the component rather than when interpreting the URL. So each click drifted further out of sync.How the bug plays out:
1 ) Initial load at ?m=history (no ?page)
right)
The fix:
Align the handler, the URL, and the template on 1-indexed pages to match every other paginated page on the site (admin/people/edits, loan_history, admin/memory).
Also replaces the brittle
len(h) == 20has-next check with alimit + 1fetch so the Next arrow no longer appears on exact-20-item last pages.Testing
Visit a history page with more than 20 revisions and navigate forward and backwards with pagination.
Screenshot
Stakeholders
@cdrini