Sitemaps abilities: register status reads + rebuild dispatch via Registrar#48767
Sitemaps abilities: register status reads + rebuild dispatch via Registrar#48767enejb wants to merge 4 commits into
Conversation
|
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
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: 🔴 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: Follow this PR Review Process:
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:
If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. |
Code Coverage SummaryCoverage changed in 1 file.
1 file is newly checked for coverage.
|
Implements the Sitemaps module slice of the Abilities Everywhere plan (§3.3).
Summary
Sitemaps_Abilities(Registrar subclass) undermodules/sitemaps/abilities/, wired from the bottom ofmodules/sitemaps.phpso it only registers while the Sitemaps module is active.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 onedit_posts(content managers can inspect sitemap state). Annotated readonly + idempotent.jetpack-sitemaps/request-rebuild— zero-arg dispatch returning{ dispatched, status }withstatusinqueued/running/already_running. Gated onmanage_options(admin only). Annotated non-readonly + idempotent: returnsdispatched=false+status=runningwhen thejetpack-sitemap-state-locktransient is set (build in flight),dispatched=false+status=queuedwhen a cron tick is already scheduled, and otherwise schedules a single-eventjp_sitemap_cron_hooktick and returnsdispatched=true.tests/php/src/Sitemaps_Abilities_Test.phpmirrorsMonitor_Abilities_Test: abstract getters, Registrar wiring (gate filter, per-ability allow-list, category auto-injection), permission callbacks (admin/editor/subscriber/anonymous matrix),get_statushappy path + module-off + news-filter,last_build_atderivation from the state machine (including the epoch sentinel),request_rebuildthree-state dispatch + idempotency, and the gated-registration contract when the module is inactive.Sitemaps_Abilities_Test_Stubtest 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
GET /wp-json/wp-abilities/v1/abilitiesdoes not list anyjetpack-sitemaps/*entries.POST /wp-json/wp-abilities/v1/run/jetpack-sitemaps/get-statusas an editor returns the full eight-key shape withactive=true.POST /wp-json/wp-abilities/v1/run/jetpack-sitemaps/request-rebuildas admin returnsdispatched=true,status=queued. A second immediate call returnsdispatched=false,status=queued.jetpack-sitemap-state-locktransient set, the same call returnsdispatched=false,status=running.