Skip to content

Use the REST pagination signal for tag lists#25804

Open
jkmassel wants to merge 1 commit into
bugfix/selfhosted-taxonomy-restfrom
bugfix/tags-pagination-signal
Open

Use the REST pagination signal for tag lists#25804
jkmassel wants to merge 1 commit into
bugfix/selfhosted-taxonomy-restfrom
bugfix/tags-pagination-signal

Conversation

@jkmassel

@jkmassel jkmassel commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

Suggestion for #25767 (base: bugfix/selfhosted-taxonomy-rest) — fixes a tag-list pagination bug.

Summary

  • TagsViewModel inferred hasMore from remoteTags.count == 100, so a tag list whose size is an exact multiple of the page size (100, 200, …) requested a page past the last one.
  • Once Fixes fetching terms on XML-RPC disabled sites #25767 routes built-in tags through AnyTermService (wp/v2, page-number paging), that over-page request returns 400 rest_term_invalid_page_number, surfacing a stuck pagination error footer. The prior offset-based path returned an empty page and stopped cleanly.

Root Cause

AnyTermService.getTags discarded the response's nextPageParams — wp/v2's authoritative "is there another page" signal — and returned only response.data, forcing TagsViewModel to guess hasMore from the item count. That guess is wrong exactly when the last page is full.

Fix

TaxonomyServiceProtocol.getTags now returns (terms:hasMore:):

  • AnyTermService derives hasMore from response.nextPageParams != nil (the wp/v2 signal).
  • TagsService keeps the count == pageSize check, which is safe for its offset-based XML-RPC / WP.com remotes — an over-offset request returns an empty page, not a 400.
  • TagsViewModel uses the returned hasMore instead of count == 100.

Contained to the two getTags implementations and their single caller; no other conformers.

Test Plan

  • Self-hosted (application password) or WP.com site with exactly 100 tags: open the tag picker, scroll to the bottom — no error footer, pagination stops cleanly.
  • Site with a non-multiple-of-100 tag count (e.g. 150): all tags still load across pages.
  • Custom taxonomy term lists still page correctly.
  • Legacy self-hosted (XML-RPC, no application password) tag list still loads.

TagsViewModel inferred `hasMore` from `count == 100`, so a tag list whose size is an exact multiple of the page size requested a page past the last one. On the wp/v2 path that returns 400 (rest_term_invalid_page_number), surfacing a stuck pagination error where the offset-based path stopped cleanly.

Return `hasMore` from `getTags` instead: AnyTermService derives it from the response's `nextPageParams`; TagsService keeps the count check that is safe for its offset-based remotes.
@wpmobilebot

Copy link
Copy Markdown
Contributor
App Icon📲 You can test the changes from this Pull Request in Jetpack by scanning the QR code below to install the corresponding build.
App NameJetpack
ConfigurationRelease-Alpha
Build Number33239
VersionPR #25804
Bundle IDcom.jetpack.alpha
Commitf25653d
Installation URL1daa6jonabf38
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@crazytonyli

Copy link
Copy Markdown
Contributor

that over-page request returns 400 rest_term_invalid_page_number

This error code does not seem to exist.

Here are curl test results:

$ curl -s --include -u "demo:${APP_PASSWORD}" 'https://frog-of-gamefowls.jurassic.ninja/wp-json/wp/v2/tags?context=view&per_page=100&page=2'
HTTP/2 200
x-wp-total: 100
x-wp-totalpages: 1

[]%

$ curl -s --include -u "demo:${APP_PASSWORD}" 'https://frog-of-gamefowls.jurassic.ninja/wp-json/wp/v2/tags?context=view&per_page=100&page=3'
HTTP/2 200
x-wp-total: 100
x-wp-totalpages: 1

[]%

I also can't reproduce the issue in the app.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants