REST API: remove search and page from the view config schema. - #12766
REST API: remove search and page from the view config schema.#12766oandregal wants to merge 1 commit into
search and page from the view config schema.#12766Conversation
`search` and `page` are managed via the URL, which is their only source of truth, so they should not be persisted as part of a view configuration. Removes both properties from the shared ViewBase schema in `WP_REST_View_Config_Controller`, updates the `WP_View_Config_Data` docblock example that used `search`, and adds a test asserting neither property is declared by any view in the item schema.
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the 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. |
There was a problem hiding this comment.
🟡 Not ready to approve
The new schema test misses some view schemas present in the item schema (e.g., picker layouts), leaving a gap where search/page could be reintroduced without failing the test.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.
Pull request overview
This PR updates the REST View Config schema to stop treating search and page as persisted view configuration properties, since they are URL-managed state and should not be stored in view configs.
Changes:
- Removes
searchandpagefrom the sharedViewBaseschema inWP_REST_View_Config_Controller. - Updates the
WP_View_Config_Datadocblock example to avoid usingsearch. - Adds a PHPUnit test asserting
searchandpageare not declared by view schemas in the item schema.
File summaries
| File | Description |
|---|---|
| tests/phpunit/tests/rest-api/rest-view-config-controller.php | Adds a schema assertion test intended to ensure URL-managed properties are not part of any view schema. |
| src/wp-includes/rest-api/endpoints/class-wp-rest-view-config-controller.php | Removes search/page from the shared view schema and documents why. |
| src/wp-includes/class-wp-view-config-data.php | Updates documentation examples to avoid using removed schema properties. |
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 1
- Review effort level: Low
We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.
| $views = array( | ||
| 'default_view' => $schema['properties']['default_view']['properties'], | ||
| 'view_list item view' => $schema['properties']['view_list']['items']['properties']['view']['properties'], | ||
| 'default_layouts.table' => $schema['properties']['default_layouts']['properties']['table']['properties'], | ||
| 'default_layouts.grid' => $schema['properties']['default_layouts']['properties']['grid']['properties'], | ||
| 'default_layouts.list' => $schema['properties']['default_layouts']['properties']['list']['properties'], | ||
| 'default_layouts.activity' => $schema['properties']['default_layouts']['properties']['activity']['properties'], | ||
| ); |
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. |
ntsekouras
left a comment
There was a problem hiding this comment.
Backported changes look good, thanks! I'm approving now, since the GB PR doesn't expect any other PHP changes is almost ready.
Trac ticket https://core.trac.wordpress.org/ticket/65577
Backports WordPress/gutenberg#80832
Follow-up to #12391
searchandpageare managed via the URL, which is their only source of truth, so they should not be persisted as part of a view configuration.Removes both properties from the shared ViewBase schema in
WP_REST_View_Config_Controller, updates theWP_View_Config_Datadocblock example that usedsearch, and adds a test asserting neither property is declared by any view in the item schema.