Skip to content

Entity Fields: Require hierarchy for the parent field - #15290

Open
drewmt wants to merge 1 commit into
WordPress:trunkfrom
drewmt:fix/non-hierarchical-parent-field
Open

drewmt wants to merge 1 commit into
WordPress:trunkfrom
drewmt:fix/non-hierarchical-parent-field

Conversation

@drewmt

@drewmt drewmt commented Oct 31, 2026 •

Copy link
Copy Markdown

Summary

Backports the PHP fix from WordPress/gutenberg#85679 for WordPress/gutenberg#85595.

A non-hierarchical custom post type can support page-attributes for ordering without supporting parent-child relationships. Core currently registers its Parent DataForm field based only on that support flag, exposing an inappropriate Parent control. Require both hierarchy and page-attributes before registering the field. Hierarchical types retain their Parent field; ordering, supports and persistence are unchanged.

The support-only parent test is replaced with all four hierarchy/support combinations. The new data provider follows current trunk's static-provider convention, and the regression test links ticket #66428. Existing upstream test teardown cleanup is preserved. The PHP runtime file matches the Gutenberg implementation byte-for-byte. No legacy React component change or unrelated cleanup is included.

Testing instructions

  1. Register a REST-enabled custom post type with hierarchical => false and supports => array( 'title', 'editor', 'page-attributes' ).
  2. Open a post of that type in the block editor. Its Parent control should not be exposed; its ordering setting must remain supported.
  3. Repeat with hierarchical => true: Parent remains available. Without page-attributes support it should not be registered in either case.
  4. Run npm run test:php -- --group entity-fields, then npm run test:php -- -c tests/phpunit/multisite.xml --group entity-fields. The new test is test_the_parent_field_requires_hierarchy_and_page_attributes in tests/phpunit/tests/entity-fields/wpRegisterCoreFieldCollections.php.

Validation

Revalidated on October 31, 2026 against Core trunk 518fcad26afd87e5422ddda0d95b6af15bea8057, with PHP 8.4.12, PHPUnit 9.6.38 and an isolated MariaDB 10.11.18 test database:

  • Failing-first check without the hierarchy guard: 4 cases / 4 assertions, exactly one expected failure for a non-hierarchical type supporting page-attributes.
  • With the fix, the complete entity-fields group including REST passed 125 tests / 458 assertions in single-site and 125 tests / 458 assertions in multisite.
  • Repository coding standards for the changed test, WordPress-Core coding standards for the generated PHP runtime file, PHP syntax and git diff --check passed.
  • Existing PHPUnit XML-schema deprecation warning remains. No tests or checks were disabled. The full Core suite and a Core browser smoke test were not run locally; other PHP versions were not tested locally.

Suggested milestone: 7.2, subject to maintainer triage; no release assignment is claimed. The Gutenberg backport-changelog entry now links this Core PR: https://github.com/WordPress/gutenberg/blob/8d32edb4385222d532b22cf8d6bf940a96ca29ef/backport-changelog/7.2/15290.md.

CI follow-up

At head 28a3eeb6f41b2a4f80f884eb83a075535cd539eb, Core CI rebuilds the tracked PHP file from its older pinned Gutenberg build, restoring the support-only Parent condition. This causes the tracked-file build checks and the new regression case to fail. The companion Gutenberg fix must be included in Core's Gutenberg source pin/build for regeneration to preserve the guard. Exact build and PHPUnit log evidence is recorded at https://core.trac.wordpress.org/ticket/66428#comment:2. No tests or workflow checks were disabled.

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

Use of AI Tools


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

@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.

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

Props linewebdigital.

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


Props Bot commands

You can trigger Props Bot actions by commenting on this PR:

  • @propsbot add <username> to give props to a GitHub user. Requires write access.
  • @propsbot remove <username> to leave a user out of the props. Requires write access.
  • @propsbot refresh to refresh this list. Adding the props-bot label works too.

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.

1 participant