Import abilities: register get-config + cleanup-meta via Registrar#48759
Import abilities: register get-config + cleanup-meta via Registrar#48759enejb wants to merge 1 commit 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! |
Code Coverage SummaryCoverage changed in 1 file.
1 file is newly checked for coverage.
|
Summary
Adds the WordPress Abilities API surface for the
automattic/jetpack-importpackage via aRegistrarsubclass. References plan §4.2 ("Ship Import abilities").The Import package is the backend half of the WPCOM Unified Importer — a stateless set of
/jetpack/v4/import/*REST endpoints. It has no job lifecycle (no queue, no persistent state, no list-of-jobs surface) and no agent-actionable start/cancel write surface beyond a per-entity create RPC that should not be exposed directly to agents. Per the ship task's "don't fabricate write endpoints" guidance, the abilities map only to endpoints that actually exist:jetpack-import/get-configwraps/import/start::get_item()— returns{ max_batch_items, max_execution_time, max_input_time, mime_types, posts_max_id, version }. Read-only, idempotent.jetpack-import/cleanup-metawraps/import/end::cleanup_database()— deletes the_jetpack_import_idrows frompostmeta,commentmeta,termmeta. Destructive but idempotent (second call returns zeros).Both abilities reuse the REST controller's
current_user_can( 'import' )gate exactly — no widening of the existing access surface. Registration is gated behind the sharedjetpack_wp_abilities_enabledfilter (defaults tofalse) insideRegistrar::init(), so this rolls out opt-in per site.The per-entity create endpoints (posts/pages/comments/menus/templates/…) are deliberately not exposed as abilities — they are a private RPC surface for the Unified Importer orchestrator, not direct-call surfaces for AI agents.
Notes
class-main.php::configure()(the package's existing bootstrap), mirroring the Stats package pattern. The Import package has noactions.php, so wiring lives inMainrather than a separate file.require-dev) since the package has no WordPress test environment — mirrors thewp-abilitiespackage's ownRegistrarTest. 17 tests, 85 assertions.tests/.phpcs.dir.xmladopts theJetpack-Testsruleset so test-file naming + globals follow the relaxed test conventions used by the other ability-shipping packages.WP_Errorshim lives intests/php/class-wp-error.phpso thecleanup_meta()error path is testable without spinning up WordPress.Test plan
cd projects/packages/import && composer phpunit -- --filter Import_Abilities_Test— 17/17 pass.add_filter( 'jetpack_wp_abilities_enabled', '__return_true' ), the WP abilities REST surface exposes thejetpack-importcategory with both abilities.jetpack-import/get-configas an admin returns the env snapshot; calling as a non-importuser returns 403.jetpack-import/cleanup-metaafter an import returns non-zero counts; a second call returns{ ..., changed: false }.