diff --git a/CHANGELOG.md b/CHANGELOG.md index 92c7f62..d0ad47a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,6 +34,22 @@ the initial snapshot of the prototype. `core-experimental/` abilities keep the no-promises experimental tier; `core/` and `wordpress/` semantics are untouched. +- **Breaking:** Moved the `core/content-*` write trio back from tier `stable` + to the experimental tier: `core/content-create`, `core/content-update`, and + `core/content-delete` became `core-experimental/content-create`, + `core-experimental/content-update`, and `core-experimental/content-delete` + ([issue #17](https://github.com/WordPress/abilities/issues/17); staging + decision per [PR #33](https://github.com/WordPress/abilities/pull/33)). The + core proposal ([Trac #66706](https://core.trac.wordpress.org/ticket/66706), + WordPress/wordpress-develop PR #16028) is still in review with the shape + still moving, so the trio incubates until it lands in core — when the + canonical `core/` versions sync back, superseding the experimental copies. + Per the rename protocol (NAME-LIFECYCLE.md) the manifest entries record the + previous `core/` names under `renamed_from` (stamped into each ability's + `meta.renamed_from`); the `core/` names shipped by the 0.1.0 release stop + working with the release carrying this change, and no alias period is + offered. + ### Added - Repository scaffold and tooling: Composer contract for `wordpress/abilities` diff --git a/README.md b/README.md index 573a98e..cb2e43f 100644 --- a/README.md +++ b/README.md @@ -138,9 +138,9 @@ Full rules, the promotion path, and the rename protocol are in | `core/content-query` | core | content | Backport of the readonly content query ability landed in WordPress core 7.2 (`core_since: 7.2`). On 7.2+ core provides it and the Registrar skips it; on 6.9–7.1 the package serves it under the same name. Requires the `show_in_abilities` support feature (polyfilled where core lacks it). | | `core/settings-get` | core | site | Backport of the readonly settings get ability landed in WordPress core 7.2 (`core_since: 7.2`). On 7.2+ core provides it and the Registrar skips it; on 6.9–7.1 the package serves it under the same name. Requires the `setting_show_in_abilities` support feature (polyfilled where core lacks it: core's own settings are flagged and registered before the ability reads them, as on 7.2). | | `core/users-query` | core | user | Backport of the readonly users query ability landed in WordPress core 7.2 (`core_since: 7.2`). On 7.2+ core provides it and the Registrar skips it; on 6.9–7.1 the package serves it under the same name. Needs no support feature beyond the Abilities API. | -| `core/content-create` | stable | content | Port of the content create ability from [WordPress/ai PR #1025](https://github.com/WordPress/ai/pull/1025) (`core_since: null` — flips to tier `core` when it lands in WordPress core). Creates posts of types exposed to abilities under the field names `core/content-query` returns. | -| `core/content-update` | stable | content | Port of the content update ability from [WordPress/ai PR #1025](https://github.com/WordPress/ai/pull/1025) (`core_since: null` — flips to tier `core` when it lands in WordPress core). Updates a post by ID; fields left out keep their current values. | -| `core/content-delete` | stable | content | Port of the content delete ability from [WordPress/ai PR #1025](https://github.com/WordPress/ai/pull/1025) (`core_since: null` — flips to tier `core` when it lands in WordPress core). Trashes a post by ID, or deletes it permanently with `force`. | +| `core-experimental/content-create` | experimental | content | Port of the content create ability from [WordPress/ai PR #1025](https://github.com/WordPress/ai/pull/1025) (`core_since: null` — flips to tier `core` when it lands in WordPress core; incubating under the `core-experimental/` prefix until then, with the 0.1.0 `core/` names recorded under `renamed_from`). Creates posts of types exposed to abilities under the field names `core/content-query` returns. | +| `core-experimental/content-update` | experimental | content | Port of the content update ability from [WordPress/ai PR #1025](https://github.com/WordPress/ai/pull/1025) (`core_since: null` — flips to tier `core` when it lands in WordPress core; incubating under the `core-experimental/` prefix until then, with the 0.1.0 `core/` names recorded under `renamed_from`). Updates a post by ID; fields left out keep their current values. | +| `core-experimental/content-delete` | experimental | content | Port of the content delete ability from [WordPress/ai PR #1025](https://github.com/WordPress/ai/pull/1025) (`core_since: null` — flips to tier `core` when it lands in WordPress core; incubating under the `core-experimental/` prefix until then, with the 0.1.0 `core/` names recorded under `renamed_from`). Trashes a post by ID, or deletes it permanently with `force`. | | `core-experimental/media-query` | experimental | media | Port of the read-only media query ability from [WordPress/ai PR #1098](https://github.com/WordPress/ai/pull/1098) (`core_since: null` — flips to tier `core` when it lands in WordPress core). Reads media library items — a single item by ID, or a paginated filtered collection (`media`/`total`/`total_pages`) with totals; `fields` picks a subset, and raw fields require edit access. Uses the package-authored `media` category (core has no equivalent to copy). | | `core-experimental/media-upload` | experimental | media | Port of the media upload ability from [WordPress/ai PR #1104](https://github.com/WordPress/ai/pull/1104) (`core_since: null` — flips to tier `core` when it lands in WordPress core). Uploads a file from base64 `data` + `filename` (with attachment fields), or downloads an image from a `url` (parent post only). Returns the new item in the edit context; `fields` picks a subset. Requires `upload_files`; the parent and author are named-field checks. A URL upload downloads from another site (`open_world: true`), capped at the site's upload size. Uses the package-authored `media` category. | | `core-experimental/media-update` | experimental | media | Port of the media update ability from [WordPress/ai PR #1104](https://github.com/WordPress/ai/pull/1104) (`core_since: null` — flips to tier `core` when it lands in WordPress core). Updates a media item by ID with the same attachment fields (the status is validated against the attachment, so `inherit` can be kept); fields left out keep their values. Returns the updated item in the edit context. Requires edit access to the item (`edit_post` for attachments, via the same projection `core-experimental/media-query` reads with). | diff --git a/src/Content/Abstract_Content_Write.php b/src/Content/Abstract_Content_Write.php index 1806a97..8a161cd 100644 --- a/src/Content/Abstract_Content_Write.php +++ b/src/Content/Abstract_Content_Write.php @@ -7,8 +7,13 @@ * The helpers shared with `core/content-query` (read permission, post and author * lookup, field projection, post rendering) are extracted verbatim from this * package's Content_Query port of core's WP_Abilities_Content, with `private` - * relaxed to `protected` so the write ability subclasses reuse them. The write - * logic itself (create, update, delete) is a faithful port of the PR, with the + * relaxed to `protected` so the write ability subclasses reuse them. Upstream + * names the abilities `core/content-create`, `core/content-update`, and + * `core/content-delete`: while the core proposal (Trac #66706 / + * WordPress/wordpress-develop PR #16028) is in review, this package ships + * them under the experimental tier's `core-experimental/` prefix (see + * NAME-LIFECYCLE.md). The write logic itself (create, update, delete) is a + * faithful port of the PR, with the * settled divergences of the port plan: this package's dotted field paths * (`title.raw`, `content.raw`, `excerpt.raw`, `author.slug`, `date.local`, * `date.gmt`) everywhere the PR uses its flat renamed ones, the `default` text @@ -33,14 +38,14 @@ use WordPress\Abilities\Abstract_Core_Ability; /** - * Shared base for the `core/content-create`, `core/content-update`, and - * `core/content-delete` abilities. + * Shared base for the `core-experimental/content-create`, `core-experimental/content-update`, and + * `core-experimental/content-delete` abilities. * * Holds everything the three write abilities share: the post field definitions * and projection of `core/content-query` (so a post can be read and written back * unchanged), the permission and execute callbacks of each ability, and the * input schema builders. Only the Abilities API calls the callbacks: callers go - * through the registry, such as `wp_get_ability( 'core/content-create' )->execute()`, + * through the registry, such as `wp_get_ability( 'core-experimental/content-create' )->execute()`, * which validates the input and checks permissions before running them. * * @package WordPress\Abilities @@ -888,7 +893,7 @@ protected function format_date( WP_Post $post, string $field, bool $gmt ): ?stri } /** - * Permission callback for the `core/content-create` ability. + * Permission callback for the `core-experimental/content-create` ability. * * The current user must be able to create posts of the requested post type. The rest * of the input is checked during execution. @@ -912,7 +917,7 @@ protected function check_create_permission( $input = array() ): bool { } /** - * Permission callback for the `core/content-update` ability. + * Permission callback for the `core-experimental/content-update` ability. * * The post must exist in an exposed post type (and match the `type` guard when * given), and the current user must be able to edit it. The rest of the input is @@ -937,7 +942,7 @@ protected function check_update_permission( $input = array() ): bool { } /** - * Permission callback for the `core/content-delete` ability. + * Permission callback for the `core-experimental/content-delete` ability. * * The post must exist in an exposed post type (and match the `type` guard when * given), and the current user must be able to delete it. As in `core/content-query`, @@ -1137,7 +1142,7 @@ protected function get_post_by_slug( string $post_type, string $slug ): ?WP_Post } /** - * Executes the `core/content-create` ability. + * Executes the `core-experimental/content-create` ability. * * {@see WP_Ability::execute()} always runs {@see self::check_create_permission()} first, * so this re-validates the post type lookup and leaves the rest of the input to @@ -1158,7 +1163,7 @@ protected function execute_content_create( $input = array() ) { } /** - * Executes the `core/content-update` ability. + * Executes the `core-experimental/content-update` ability. * * {@see WP_Ability::execute()} always runs {@see self::check_update_permission()} first, * so this re-validates the post lookup and leaves the rest of the input to @@ -1265,7 +1270,7 @@ protected function write_content( array $input, WP_Post_Type $post_type_object, } /** - * Executes the `core/content-delete` ability. + * Executes the `core-experimental/content-delete` ability. * * {@see WP_Ability::execute()} always runs {@see self::check_delete_permission()} first; * this re-validates the lookup and, because the operation is destructive, checks the @@ -1396,7 +1401,7 @@ protected function get_content_write_properties(): array { } /** - * Builds the input schema for the `core/content-create` ability. + * Builds the input schema for the `core-experimental/content-create` ability. * * `additionalProperties: false` rejects unknown fields instead of dropping them, so e.g. * passing an `id` fails validation instead of silently creating a new post. @@ -1424,14 +1429,14 @@ protected function get_content_create_input_schema( array $post_types ): array { } /** - * Builds the input schema for the `core/content-update` ability from the create schema. + * Builds the input schema for the `core-experimental/content-update` ability from the create schema. * * The post is identified by `id`, and `type` becomes an optional guard. The status * keeps the create schema's enum, so clients can see and check the statuses that can be * set. A post with an internal status, such as `trash`, keeps it when the status is left * out; validation rejects that status before execution, even when it is the current one. * - * @param array $create_schema The input schema of the `core/content-create` ability. + * @param array $create_schema The input schema of the `core-experimental/content-create` ability. * @return array The input JSON Schema. */ protected function get_content_update_input_schema( array $create_schema ): array { @@ -1455,7 +1460,7 @@ protected function get_content_update_input_schema( array $create_schema ): arra } /** - * Builds the input schema for the `core/content-delete` ability. + * Builds the input schema for the `core-experimental/content-delete` ability. * * @param list $post_types Exposed post type names. * @return array The input JSON Schema. diff --git a/src/Content/Content_Create.php b/src/Content/Content_Create.php index 0c07c64..605d1cd 100644 --- a/src/Content/Content_Create.php +++ b/src/Content/Content_Create.php @@ -1,6 +1,6 @@ array( - 'name' => 'core/content-create', + 'core-experimental/content-create' => array( + 'name' => 'core-experimental/content-create', 'class' => Content\Content_Create::class, 'category' => 'content', - 'tier' => self::TIER_STABLE, + 'tier' => self::TIER_EXPERIMENTAL, 'min_wp_version' => '6.9', 'core_since' => null, 'requires' => array( 'show_in_abilities' ), - 'renamed_from' => null, + 'renamed_from' => 'core/content-create', 'proposal' => 'https://github.com/WordPress/ai/pull/1025', ), - 'core/content-update' => array( - 'name' => 'core/content-update', + 'core-experimental/content-update' => array( + 'name' => 'core-experimental/content-update', 'class' => Content\Content_Update::class, 'category' => 'content', - 'tier' => self::TIER_STABLE, + 'tier' => self::TIER_EXPERIMENTAL, 'min_wp_version' => '6.9', 'core_since' => null, 'requires' => array( 'show_in_abilities' ), - 'renamed_from' => null, + 'renamed_from' => 'core/content-update', 'proposal' => 'https://github.com/WordPress/ai/pull/1025', ), - 'core/content-delete' => array( - 'name' => 'core/content-delete', + 'core-experimental/content-delete' => array( + 'name' => 'core-experimental/content-delete', 'class' => Content\Content_Delete::class, 'category' => 'content', - 'tier' => self::TIER_STABLE, + 'tier' => self::TIER_EXPERIMENTAL, 'min_wp_version' => '6.9', 'core_since' => null, 'requires' => array( 'show_in_abilities' ), - 'renamed_from' => null, + 'renamed_from' => 'core/content-delete', 'proposal' => 'https://github.com/WordPress/ai/pull/1025', ), /* diff --git a/tests/Abilities/ContentCreateTest.php b/tests/Abilities/ContentCreateTest.php index d5ef680..02f4849 100644 --- a/tests/Abilities/ContentCreateTest.php +++ b/tests/Abilities/ContentCreateTest.php @@ -1,6 +1,6 @@ get_registered( 'core/content-create' ); + return WP_Abilities_Registry::get_instance()->get_registered( 'core-experimental/content-create' ); } /** @@ -263,7 +263,8 @@ public function test_registered_meta_and_schema(): void { self::assertTrue( (bool) ( $meta['public'] ?? false ) ); self::assertTrue( (bool) ( $meta['show_in_rest'] ?? false ) ); self::assertSame( 'wordpress/abilities', $meta['source'] ?? null, 'The package copy provides the trio in both environments.' ); - self::assertSame( Manifest::TIER_STABLE, $meta['stability'] ?? null ); + self::assertSame( Manifest::TIER_EXPERIMENTAL, $meta['stability'] ?? null ); + self::assertSame( 'core/content-create', $meta['renamed_from'] ?? null, 'The demoted ability records its previous core/ stable-tier name.' ); if ( method_exists( $ability, 'get_category' ) ) { self::assertSame( 'content', $ability->get_category() ); diff --git a/tests/Abilities/ContentDeleteTest.php b/tests/Abilities/ContentDeleteTest.php index 0e728f8..4721906 100644 --- a/tests/Abilities/ContentDeleteTest.php +++ b/tests/Abilities/ContentDeleteTest.php @@ -1,6 +1,6 @@ get_registered( 'core/content-delete' ); + return WP_Abilities_Registry::get_instance()->get_registered( 'core-experimental/content-delete' ); } /** @@ -208,7 +208,8 @@ public function test_registered_meta_and_schema(): void { self::assertTrue( (bool) ( $meta['public'] ?? false ) ); self::assertTrue( (bool) ( $meta['show_in_rest'] ?? false ) ); self::assertSame( 'wordpress/abilities', $meta['source'] ?? null, 'The package copy provides the trio in both environments.' ); - self::assertSame( Manifest::TIER_STABLE, $meta['stability'] ?? null ); + self::assertSame( Manifest::TIER_EXPERIMENTAL, $meta['stability'] ?? null ); + self::assertSame( 'core/content-delete', $meta['renamed_from'] ?? null, 'The demoted ability records its previous core/ stable-tier name.' ); if ( method_exists( $ability, 'get_category' ) ) { self::assertSame( 'content', $ability->get_category() ); diff --git a/tests/Abilities/ContentUpdateTest.php b/tests/Abilities/ContentUpdateTest.php index 8f899d5..4a15297 100644 --- a/tests/Abilities/ContentUpdateTest.php +++ b/tests/Abilities/ContentUpdateTest.php @@ -1,6 +1,6 @@ get_registered( 'core/content-update' ); + return WP_Abilities_Registry::get_instance()->get_registered( 'core-experimental/content-update' ); } /** @@ -204,7 +204,8 @@ public function test_registered_meta_and_schema(): void { ); self::assertTrue( (bool) ( $meta['public'] ?? false ) ); self::assertSame( 'wordpress/abilities', $meta['source'] ?? null ); - self::assertSame( Manifest::TIER_STABLE, $meta['stability'] ?? null ); + self::assertSame( Manifest::TIER_EXPERIMENTAL, $meta['stability'] ?? null ); + self::assertSame( 'core/content-update', $meta['renamed_from'] ?? null, 'The demoted ability records its previous core/ stable-tier name.' ); if ( method_exists( $ability, 'get_category' ) ) { self::assertSame( 'content', $ability->get_category() ); diff --git a/tests/RegistrarTest.php b/tests/RegistrarTest.php index e89e0ba..9fc98dd 100644 --- a/tests/RegistrarTest.php +++ b/tests/RegistrarTest.php @@ -535,10 +535,10 @@ public function test_public_only_and_consumer_filter_gates(): void { * first init window ran under the version floor, so the name is * not in-process registered here either. */ - self::assertFalse( Registrar::register( 'core/content-create', array( 'filter' => $filter ) ), 'Consumer filter returning false skips.' ); + self::assertFalse( Registrar::register( 'core-experimental/content-create', array( 'filter' => $filter ) ), 'Consumer filter returning false skips.' ); self::assertCount( 1, $captured, 'The filter receives exactly the attempted ability.' ); - self::assertSame( 'core/content-create', $captured[0][0] ); - self::assertSame( Manifest::get( 'core/content-create' ), $captured[0][1], 'The filter receives the manifest entry.' ); + self::assertSame( 'core-experimental/content-create', $captured[0][0] ); + self::assertSame( Manifest::get( 'core-experimental/content-create' ), $captured[0][1], 'The filter receives the manifest entry.' ); /* * P7 core-skip precedence: on a host where core itself provides @@ -723,7 +723,7 @@ static function (): void { // category and the other registrations resolve without wrong-usage // traffic on every environment. self::assertTrue( wp_has_ability_category( 'content' ), 'P8: the manifest category is registered after the replayed window.' ); - self::assertTrue( wp_has_ability( 'core/content-create' ), 'P8: the manifest abilities register in the replayed window.' ); + self::assertTrue( wp_has_ability( 'core-experimental/content-create' ), 'P8: the manifest abilities register in the replayed window.' ); self::reset_wrong_usage(); self::assert_no_wrong_usage(); } @@ -784,7 +784,7 @@ static function (): void { // Host-owned category source (see above): no manifest slug can // witness the opt-out; assert the settled, silent state instead. remove_filter( 'wordpress_abilities_declare_categories', '__return_false' ); - self::assertTrue( wp_has_ability( 'core/content-create' ), 'P8: manifest abilities register where the host registers the categories themselves.' ); + self::assertTrue( wp_has_ability( 'core-experimental/content-create' ), 'P8: manifest abilities register where the host registers the categories themselves.' ); self::assert_no_wrong_usage( 'P8: the opted-out declaration is silent on a host whose own registrar provides the categories.' ); } else { foreach ( $missing as $missing_slug ) { @@ -812,11 +812,11 @@ static function (): void { if ( wp_has_ability_category( 'content' ) ) { self::assertTrue( - wp_has_ability( 'core/content-create' ), + wp_has_ability( 'core-experimental/content-create' ), 'P8: the abilities of host-provided categories register despite the opted-out declaration of another manifest category.' ); } else { - self::assertFalse( wp_has_ability( 'core/content-create' ), 'P8: nothing registers when the host provides no manifest category.' ); + self::assertFalse( wp_has_ability( 'core-experimental/content-create' ), 'P8: nothing registers when the host provides no manifest category.' ); } // Restore the boot for the suites that read it after this class: @@ -835,7 +835,7 @@ static function (): void { sprintf( 'P8: restored — the package-declared %1$s category is declared again once the filter is removed.', $restored_slug ) ); } - self::assertTrue( wp_has_ability( 'core/content-create' ), 'P8: restored — the manifest abilities register again for the following suites.' ); + self::assertTrue( wp_has_ability( 'core-experimental/content-create' ), 'P8: restored — the manifest abilities register again for the following suites.' ); // The restored boot must have registered quietly from the Registrar's // side: no Gate-8 rejection, no category complaints. Only the @@ -923,7 +923,7 @@ static function (): void { if ( array() === $missing ) { // Host-provided categories (7.2+ core, or a consumer plugin): the // late first contact is safe and silent. - self::assertTrue( wp_has_ability( 'core/content-create' ), 'P8: a late first contact registers where the host provides the manifest categories.' ); + self::assertTrue( wp_has_ability( 'core-experimental/content-create' ), 'P8: a late first contact registers where the host provides the manifest categories.' ); self::assert_no_wrong_usage( 'P8: a late first contact is silent where the host provides the manifest categories.' ); } else { // At least one package-declared-only category: the abilities that @@ -938,11 +938,11 @@ static function (): void { if ( wp_has_ability_category( 'content' ) ) { self::assertTrue( - wp_has_ability( 'core/content-create' ), + wp_has_ability( 'core-experimental/content-create' ), 'P8: the abilities of host-provided categories register despite the missing declaration of another manifest category.' ); } else { - self::assertFalse( wp_has_ability( 'core/content-create' ), 'P8: nothing registers when the first contact is late on a host that provides no manifest category.' ); + self::assertFalse( wp_has_ability( 'core-experimental/content-create' ), 'P8: nothing registers when the first contact is late on a host that provides no manifest category.' ); } $messages = self::$wrong_usage['WordPress\Abilities\Registrar::try_register'] ?? array(); @@ -991,7 +991,7 @@ static function (): void { sprintf( 'P8: restored — the package-declared %1$s category is declared again.', $restored_slug ) ); } - self::assertTrue( wp_has_ability( 'core/content-create' ), 'P8: restored — the manifest abilities register again for the following suites.' ); + self::assertTrue( wp_has_ability( 'core-experimental/content-create' ), 'P8: restored — the manifest abilities register again for the following suites.' ); $registrar_traffic = array_intersect_key( self::$wrong_usage, @@ -1130,7 +1130,7 @@ public function test_deferred_registration_preloads_features_at_priority_one(): $before = $hook ? count( $hook->callbacks[1] ?? array() ) : 0; $vetoed = static function ( string $name ): bool { - return 'core/content-create' !== $name; + return 'core-experimental/content-create' !== $name; }; Registrar::register_all( array( 'filter' => $vetoed ) ); Registrar::register( 'core/settings-get' ); @@ -1155,7 +1155,7 @@ static function (): void { WP_Abilities_Registry::get_instance(); } ); - self::assertTrue( wp_has_ability( 'core/content-create' ), 'Restored: the manifest abilities register again for the following suites.' ); + self::assertTrue( wp_has_ability( 'core-experimental/content-create' ), 'Restored: the manifest abilities register again for the following suites.' ); self::reset_wrong_usage(); } } diff --git a/tools/wordpress-abilities-bridge/README.md b/tools/wordpress-abilities-bridge/README.md index bc808fc..cafc8d3 100644 --- a/tools/wordpress-abilities-bridge/README.md +++ b/tools/wordpress-abilities-bridge/README.md @@ -70,8 +70,8 @@ resolves automatically), or set `WP_ABILITIES_PACKAGE_PATH` / the Log in as an admin: a "WordPress Abilities Bridge" admin notice reports the API provider, the autoloader state, and the registration state of each -manifest ability (`core/content-query`, `core/content-create`, -`core/content-update`, `core/content-delete`). Then use your abilities +manifest ability (`core/content-query`, `core-experimental/content-create`, +`core-experimental/content-update`, `core-experimental/content-delete`). Then use your abilities consumer plugin as usual. ## Notes