Skip to content

Sitemaps abilities: register status reads + rebuild dispatch via Registrar#48767

Open
enejb wants to merge 4 commits into
trunkfrom
add/ship-sitemaps-abilities
Open

Sitemaps abilities: register status reads + rebuild dispatch via Registrar#48767
enejb wants to merge 4 commits into
trunkfrom
add/ship-sitemaps-abilities

Conversation

@enejb
Copy link
Copy Markdown
Member

@enejb enejb commented May 13, 2026

Implements the Sitemaps module slice of the Abilities Everywhere plan (§3.3).

Summary

  • Adds Sitemaps_Abilities (Registrar subclass) under modules/sitemaps/abilities/, wired from the bottom of modules/sitemaps.php so it only registers while the Sitemaps module is active.
  • Registers two abilities under category jetpack-sitemaps:
    • jetpack-sitemaps/get-status — zero-arg read returning { active, url, last_build_at, post_count, page_count, news_sitemap_enabled, master_sitemap_url, last_error }. Gated on edit_posts (content managers can inspect sitemap state). Annotated readonly + idempotent.
    • jetpack-sitemaps/request-rebuild — zero-arg dispatch returning { dispatched, status } with status in queued / running / already_running. Gated on manage_options (admin only). Annotated non-readonly + idempotent: returns dispatched=false + status=running when the jetpack-sitemap-state-lock transient is set (build in flight), dispatched=false + status=queued when a cron tick is already scheduled, and otherwise schedules a single-event jp_sitemap_cron_hook tick and returns dispatched=true.
  • Test coverage in tests/php/src/Sitemaps_Abilities_Test.php mirrors Monitor_Abilities_Test: abstract getters, Registrar wiring (gate filter, per-ability allow-list, category auto-injection), permission callbacks (admin/editor/subscriber/anonymous matrix), get_status happy path + module-off + news-filter, last_build_at derivation from the state machine (including the epoch sentinel), request_rebuild three-state dispatch + idempotency, and the gated-registration contract when the module is inactive.
  • A Sitemaps_Abilities_Test_Stub test double overrides the protected seams (get_master_sitemap_url, get_last_build_at, count_published) so success-path tests don't need a permalink/rewrite stack or wp_count_posts factory.

Test plan

  • CI green: PHPUnit (PHP 7.2 → 8.4), PHPCS, Phan.
  • On a site with the Sitemaps module off, GET /wp-json/wp-abilities/v1/abilities does not list any jetpack-sitemaps/* entries.
  • On a site with the Sitemaps module on:
    • POST /wp-json/wp-abilities/v1/run/jetpack-sitemaps/get-status as an editor returns the full eight-key shape with active=true.
    • As an anonymous / subscriber user, the same call returns a 403.
    • POST /wp-json/wp-abilities/v1/run/jetpack-sitemaps/request-rebuild as admin returns dispatched=true, status=queued. A second immediate call returns dispatched=false, status=queued.
    • With the jetpack-sitemap-state-lock transient set, the same call returns dispatched=false, status=running.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 13, 2026

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 add/ship-sitemaps-abilities branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack add/ship-sitemaps-abilities

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 github-actions Bot added [Feature] Sitemaps [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Status] In Progress [Tests] Includes Tests labels May 13, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 13, 2026

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 🤖


🔴 Action required: Please include detailed testing steps, explaining how to test your change, like so:

## Testing instructions:

* Go to '..'
*

🔴 Action required: We would recommend that you add a section to the PR description to specify whether this PR includes any changes to data or privacy, like so:

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

My PR adds *x* and *y*.

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!


Jetpack plugin:

The Jetpack plugin has different release cadences depending on the platform:

  • WordPress.com Simple releases happen as soon as you deploy your changes after merging this PR (PCYsg-Jjm-p2).
  • WoA releases happen weekly.
  • Releases to self-hosted sites happen monthly:
    • Scheduled release: June 2, 2026
    • Code freeze: June 1, 2026

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.

@github-actions github-actions Bot added the [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. label May 13, 2026
@jp-launch-control
Copy link
Copy Markdown

jp-launch-control Bot commented May 13, 2026

Code Coverage Summary

Coverage changed in 1 file.

File Coverage Δ% Δ Uncovered
projects/plugins/jetpack/modules/sitemaps/sitemaps.php 76/222 (34.23%) -0.31% 2 ❤️‍🩹

1 file is newly checked for coverage.

File Coverage
projects/plugins/jetpack/modules/sitemaps/abilities/class-sitemaps-abilities.php 106/116 (91.38%) 💚

Full summary · PHP report · JS report

@enejb enejb marked this pull request as ready for review May 15, 2026 19:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Feature] Sitemaps [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Status] In Progress [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. [Tests] Includes Tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant