Make WordPress Core

Opened 3 months ago

Closed 3 months ago

Last modified 12 days ago

#65355 closed enhancement (fixed)

Abilities API: Unify schema conventions across core abilities

Reported by: gziolo Owned by: gziolo
Priority: normal Milestone: 7.1
Component: Abilities API Version:
Severity: normal Keywords: has-patch has-unit-tests has-dev-note
Cc: Focuses:

Description

The three core abilities shipped in 6.9.0 (core/get-site-info, core/get-user-info, core/get-environment-info) have drifted in small but visible ways. This ticket proposes a quality pass so they share a single blueprint.

Proposed Changes

  • Every output property should declare both title and description, reusing existing WP Admin translations where possible.
  • core/get-environment-info should gain the optional fields input parameter already supported by the other two.
  • core/get-user-info should be exposed via REST (show_in_rest => true) so clients can discover it under /wp-json/wp-abilities/v1/abilities.
  • Property titles should be normalized to Title Case.

Each change should be accompanied by unit tests so the unified contract is enforced going forward.

Change History (7)

This ticket was mentioned in PR #11984 on WordPress/wordpress-develop by @gziolo.


3 months ago
#1

  • Keywords has-patch has-unit-tests added

## Summary

The three core abilities shipped in 6.9.0 (core/get-site-info, core/get-user-info, core/get-environment-info) drifted in small but visible ways. This PR aligns them on a shared blueprint so they're predictable to consume from REST clients and easier to extend.

  • Every output property declares both title and description, reusing existing WP Admin translations where possible.
  • core/get-environment-info accepts the optional fields input parameter already supported by the other two, with an enum of valid keys.
  • core/get-user-info is exposed via REST (show_in_rest => true) so clients can discover and invoke it under /wp-json/wp-abilities/v1/abilities.
  • Property titles are normalized to Title Case. db_server_info is relabeled Database Server Info since \$wpdb->db_server_info() returns vendor+version, not just a version.
  • Registration tests lock the exact ordered set of property keys on both the input enum and the output properties, so any future field addition forces a test update.

## Test plan

  • [ ] npm run test:php -- --filter=Tests_Abilities_API_WpRegisterCoreAbilities is green
  • [ ] core/get-user-info is listed at /wp-json/wp-abilities/v1/abilities for an authenticated user
  • [ ] core/get-environment-info accepts {"fields":["php_version"]} and returns only that key
  • [ ] Unknown field names on any of the three abilities yield an ability_invalid_input error
  • [ ] npm run env:composer -- lint -- src/wp-includes/abilities.php reports no violations
  • [ ] npm run typecheck:php passes

🤖 Generated with Claude Code

#2 @gziolo
3 months ago

  • Owner set to gziolo

#3 @gziolo
3 months ago

  • Type task (blessed)enhancement

#4 @gziolo
3 months ago

  • Version 6.9

#5 @gziolo
3 months ago

  • Resolutionfixed
  • Status assignedclosed

In 62426:

Abilities API: Unify schema conventions across core abilities

Align core/get-site-info, core/get-user-info, and core/get-environment-info on a shared blueprint: every output property carries a Title Case title and a description, core/get-environment-info gains the optional fields input parameter the other two already accept, and core/get-user-info is exposed via REST. Descriptions are also tightened for programmatic consumers, and registration tests now lock the exact ordered set of property keys.

Props gziolo, westonruter.
Fixes #65355.

#6 @milana_cap
2 weeks ago

  • Keywords needs-dev-note added

#7 @milana_cap
12 days ago

  • Keywords has-dev-note added; needs-dev-note removed
Note: See TracTickets for help on using tickets.