Skip to content

SEO: page through the Content tab's posts and pages#50411

Open
xavier-lc wants to merge 4 commits into
trunkfrom
fix/seo-content-tab-post-cap
Open

SEO: page through the Content tab's posts and pages#50411
xavier-lc wants to merge 4 commits into
trunkfrom
fix/seo-content-tab-post-cap

Conversation

@xavier-lc

@xavier-lc xavier-lc commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Fixes JETPACK-1847

Proposed changes

  • Page through the Content tab's posts and pages. The tab made a single per_page=100 request per post type and merged the results, so a site with more than 100 posts (or 100 pages) silently dropped the overflow — no pagination, no notice. An owner could conclude those posts had no SEO gaps because they were never listed. useSeoPosts now walks each collection using the total page count core-data derives from X-WP-TotalPages.

  • Fix the Content tab's search box, which matched nothing..

Related product discussion/links

Does this pull request change what data or activity we track or use?

No.

Testing instructions

Needs a site with more than 100 posts and more than 100 pages — the bug is invisible below that.

  • On a Jurassic Ninja instance, seed content over SSH:
    wp post generate --count=2500 --post_type=post --post_status=publish
    wp post generate --count=150  --post_type=page --post_status=publish
    
  • Activate this PR under Jetpack on the Jetpack Beta Tester page.
  • Go to Jetpack → SEO → Content.
    • Before: exactly 200 rows (100 posts + 100 pages), 10 pages of results, no indication anything is missing.
    • After: every published post and page — 2,652 rows across 133 pages of results with the seed above. The Network panel shows one request per page of each collection (27 for the seed above).
  • Type Page into the search box.
    • Before: "No results", regardless of what you type.
    • After: the page rows match. Typing part of an SEO title or meta description matches the row it belongs to; typing set or not_set matches nothing (it searches the content, not the badge label).
  • Open a row's SEO editor, change a field, save — the row's badges should still update in place without a reload.

Performance note

Once the total is known, every remaining page is requested at once. A host serves only as many as it has PHP workers (~4 concurrent, ~1s each on a stock Atomic sandbox), so ~2.5k posts load in ~6s and the cost grows linearly; tens of thousands of posts would mean hundreds of concurrent WP_Query-with-meta requests.

Throttling that fan-out to a sliding window of 5 pages per type was tried and measured: achieved concurrency fell from ~4 to ~2.4 (each slide waits on a store update and a React commit), so the same site took ~10s and a larger one would take longer, not shorter. The window only lowers peak socket count, so it was dropped. The change that actually scales is server-side pagination, which core REST can't back today — no collection spans two post types, and none filters on the SEO post meta the tab's filters read. Hence the client-side merge. Worth its own issue under JETPACK-1843, alongside JETPACK-1796 (custom post types), which needs the same endpoint.

Xavier Lozano Carreras and others added 4 commits July 10, 2026 13:33
`useEntityRecords` resolves exactly one query per call, which is a dead
end for paging: the number of pages isn't known until page 1 comes back,
and hooks can't be called in a loop. Drop to the selectors the wrapper
already calls — same store, same entity cache, same resolvers — behind a
`selectPostType` helper mapped over the post types the tab covers.

No behaviour change: still one `per_page=100` request per type, and
`hasFinishedResolution` matches the wrapper's `hasResolved` exactly
(both count a failed request as done rather than spinning forever).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The tab made one `per_page=100` request per post type and merged the
results, so a site with more than 100 posts (or 100 pages) silently
dropped the overflow — no pagination, no notice. An owner could conclude
those posts had no SEO gaps because they weren't listed at all.

Page through each collection instead, using the total page count
core-data derives from `X-WP-TotalPages`. Selecting a page that hasn't
been fetched starts its resolver, so the loop both reads and drives the
requests: page 1 of each type goes out first, then every remaining page
once the total is known.

Verified on a site with 2502 posts + 150 pages: 2652 rows where trunk
showed 200, via 27 REST requests, 79kB transferred, ~6s to load. The
host serves ~4 requests concurrently (~1s each), so load time grows
linearly with content.

Throttling the fan-out to a sliding window of 5 pages per type was tried
and measured. It cut achieved concurrency from ~4 to ~2.4, because each
slide waits on a store update and a React commit: the same site took
~10s, and a much larger site would take longer, not shorter. The window
only lowers peak socket count, so it was dropped. What actually scales is
server-side pagination, which core REST can't back today — it offers no
collection spanning two post types, and no filtering on the SEO post
meta the tab's filters read. Hence the client-side merge, and hence the
comment pointing the next reader at the real fix.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
DataViews only matches the search string against fields that opt in with
`enableGlobalSearch`, which defaults to false. No field on the Content
tab set it, so `.some()` ran over an empty list of searchable fields and
every row was filtered out: typing anything produced "No results", even
"Page" on a site full of pages.

Search the title, the SEO title and the meta description. The latter two
rendered a Set/Not set badge and their `getValue` returned those sentinel
strings, so enabling the flag alone would have matched the badge text
rather than the content — searching "set" would return every row with an
SEO title. They now return the underlying text; the badges are drawn by
`render` from the `has*` flags, and the set/not-set state keeps its own
filter-only field.

Verified against the real `filterSortAndPaginate`: "Page" matches the
page rows, "greeting" matches an SEO title, "feline" matches a meta
description, and "set"/"not_set" match nothing.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@xavier-lc xavier-lc added the [Status] Needs Review This PR is ready for review. label Jul 10, 2026
@xavier-lc xavier-lc self-assigned this Jul 10, 2026
@github-actions

github-actions Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.

  • To test on WoA, go to the Plugins menu on a WoA dev site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta, select your plugin (Jetpack), and enable the fix/seo-content-tab-post-cap branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack fix/seo-content-tab-post-cap

Interested in more tips and information?

  • In your local development environment, use the jetpack rsync command to sync your changes to a WoA dev blog.
  • Read more about our development workflow here: PCYsg-eg0-p2
  • Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2

@github-actions

Copy link
Copy Markdown
Contributor

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ Add a "[Status]" label (In Progress, Needs Review, ...).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


Follow this PR Review Process:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Make sure to test your changes on all platforms that it applies to. You're responsible for the quality of the code you ship.
  3. You can use GitHub's Reviewers functionality to request a review.
  4. When it's reviewed and merged, you will be pinged in Slack to deploy the changes to WordPress.com simple once the build is done.

If you have questions about anything, reach out in #jetpack-developers for guidance!

@xavier-lc xavier-lc requested review from a team and angelablake July 10, 2026 14:26
@jp-launch-control

Copy link
Copy Markdown

Code Coverage Summary

This PR did not change code coverage!

That could be good or bad, depending on the situation. Everything covered before, and still is? Great! Nothing was covered before? Not so great. 🤷

Full summary · PHP report · JS report

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.

1 participant