Repository navigation
Abilities API: Add an open world annotation - #16201
avinash-addweb wants to merge 4 commits into
Conversation
Adds `open_world` as an optional `bool|null` ability annotation, defaulting to `null`, and documents it in the REST schema and the registration docblocks. Props avinashzala01. See #66799.
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
|
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
|
Thanks for working on this, @avinash-addweb! The change looks good and is almost ready. I have some feedback to share. In the places where the new annotation is documented, please add a I think we can spend some time trying to iron out the description. The phrase "public or open-ended entities" is hard to follow. The word "public" is also used by the Could you also add a test for the REST API? Query parameters arrive as strings, so it would be good to check that |
Describes the annotation in terms of systems outside of the site, so it is not confused with the `public` meta key, and uses the same wording everywhere. Adds `@since 7.3.0` entries and a REST test that the `open_world` filter value is coerced from a string. See #66799.
gziolo
left a comment
There was a problem hiding this comment.
Thanks for addressing the feedback. The changes look good to me, and the new REST test covers both true and false values.
Approving this now. I plan to leave some time for others to review and share feedback before committing it.
Trac ticket: https://core.trac.wordpress.org/ticket/66799
What
Adds
open_worldas an optionalbool|nullannotation undermeta.annotations, next toreadonly,destructiveandidempotent.true: at least one supported execution path can interact with public or open-ended entities.false: all supported execution paths stay within a bounded environment.nullor omitted: not declared. Core does not infer a value.Like the other annotations it is a hint. It does not change permissions, execution or exposure.
Changes
WP_Ability::$default_annotationsgetsopen_world => null.annotationsdocblocks inabilities-api.php,WP_Abilities_RegistryandWP_Abilitydocument the new key.WP_REST_Abilities_V1_List_Controllerdeclaresopen_worldin the response schema and in theannotationscollection filter, as it already does for the other three.Core's own abilities are not changed. They can opt in separately.
Testing
test_open_world_annotationcovers explicittrue,falseandnull, and omission.npm run test:php -- --group abilities-apipasses on single site (940 tests) and multisite (945).