Skip to content

Updates the view config endpoint with changes for WordPress 7.2 - #14495

Closed
oandregal wants to merge 2 commits into
WordPress:trunkfrom
oandregal:65981-view-config-prep
Closed

oandregal wants to merge 2 commits into
WordPress:trunkfrom
oandregal:65981-view-config-prep

Conversation

@oandregal

@oandregal oandregal commented Oct 19, 2026 •

Copy link
Copy Markdown
Member

Trac ticket https://core.trac.wordpress.org/ticket/65981

Backports view config changes for WordPress 7.2:

Use of AI Tools

AI assistance: Yes
Tool(s): Claude Code
Model(s): Opus 5.5
Used for: Implementation. Reviewed and edited by me.

oandregal and others added 2 commits October 19, 2026 14:02
Adds the missing `align` style to the author column of the `wp_block` table layout, which was left out when the "Site patterns" rename was synced in [64499].

Synced from WordPress/gutenberg#84680.

See #65981.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Moves the logic of `WP_REST_View_Config_Controller::cast_empty_objects()` into a new private `_rest_cast_empty_objects_from_schema()` function, so it can be shared with the upcoming Entity Fields controller (#66229). The protected method is kept as a wrapper for backward compatibility.

Synced from WordPress/gutenberg#84078.

See #65981.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings October 19, 2026 12:04
@github-actions

Copy link
Copy Markdown

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 props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props oandregal.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The extraction preserves normalization behavior, adds focused tests, and has no identified blocking issues.

No open issues 🎉

What changed in this PR

Extracts schema-based empty-object normalization into a shared REST helper for view configuration.

Changes:

  • Moves normalization logic into a shared helper, retaining the controller wrapper.
  • Adds tests for object, array, nested, and union schemas.
  • Sets block author column alignment to start.
File Description
tests/​phpunit/​tests/​rest-api/​restCastEmptyObjectsFromSchema.php Tests the shared normalization helper.
src/​wp-includes/​view-config.php Sets block author column alignment.
src/​wp-includes/​rest-api/​endpoints/​class-wp-rest-view-config-controller.php Delegates normalization to the shared helper.
src/​wp-includes/​rest-api.php Adds the extracted normalization helper.

Review effort: Balanced

@oandregal oandregal changed the title View config prep Updates the view config endpoint with changes for WordPress 7.2 Oct 19, 2026
@github-actions

Copy link
Copy Markdown

Test using WordPress Playground

The 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

  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

@oandregal oandregal self-assigned this Oct 19, 2026
* @param array $schema The schema node describing the value.
* @return mixed The normalized value, with empty object-typed arrays cast to objects.
*/
function _rest_cast_empty_objects_from_schema( $value, $schema ) {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This utility is now used by the view config endpoint and it's going to be used by the fields and actions endpoints as well (landing in the next hours). I thought I'd extract it first.

'styles' => array(
'author' => array(
'width' => '1%',
'align' => 'start',

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jorgefilipecosta jorgefilipecosta left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@oandregal

Copy link
Copy Markdown
Member Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants