Skip to content

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

Closed
drewmt wants to merge 3 commits into
WordPress:trunkfrom
drewmt:fix/non-hierarchical-parent-field
Closed

drewmt wants to merge 3 commits 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.

Update

Adds the docblock change to post_type_supports/parent/field.php from WordPress/gutenberg#85679, so both tracked PHP files match the Gutenberg implementation. That PR also stops the parent field's JavaScript edit from requiring a viewable post type, so hierarchical post types with public => false no longer get an empty Parent popover. That part is JavaScript built from the Gutenberg package and has no tracked file in Core; it arrives with the Gutenberg source pin.

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

github-actions Bot commented Oct 31, 2026 •

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, oandregal, jorgefilipecosta, mamaduka.

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 or WordPress.org 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.

drewmt and others added 2 commits November 20, 2026 13:40
Its definition still described the support-only condition. Matches
WordPress/gutenberg#85679.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@oandregal
oandregal force-pushed the fix/non-hierarchical-parent-field branch from 8ae3bd2 to e89ad4d Compare November 20, 2026 12:43
This updates the pinned commit hash of the Gutenberg repository from `efd7722f89ebb8abfc3607fffdd86f5e34afbd9c` to `91e24b4c4d64796704663e88fae1459882635041`.

It brings in the JavaScript part of hiding the parent controls for non-hierarchical post types, and makes the built `core-fields` files match the PHP changes of this branch.

A full list of changes included in this commit can be found on GitHub:
WordPress/gutenberg@efd7722...91e24b4.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@oandregal

Copy link
Copy Markdown
Member

These changes require pulling code from Gutenberg (built files). I've pushed a1deb93 so that CI jobs gives the true final state. This is ready to land, in my view, but I understand the release leads (@Mamaduka @peterwilsoncc) may want to time this package change differently. I'm happy to help, just wanted to bring this to your attention.

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

Comment thread package.json
},
"gutenberg": {
"sha": "efd7722f89ebb8abfc3607fffdd86f5e34afbd9c",
"sha": "91e24b4c4d64796704663e88fae1459882635041",

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.

The gutenberg hash is updated during the package update. Should the gutenberg hash (and automatic changes derived from it) be removed, leaving only the php change (a test file) on this PR? That we could commit before the pakcage upgrade would that work and the tests still pass @oandregal @drewmt?

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.

Yeah, I mentioned this below. No, tests wouldn't pass and I pushed to verify they do with these changes.

@Mamaduka

Copy link
Copy Markdown
Member

This is also blocking #16187, which includes automatically synced items, but I think it is missing the manual Unit Test sync part.

I'll handle this in the main sync commit.

Mamaduka added a commit to peterwilsoncc/wordpress-develop that referenced this pull request Nov 24, 2026
Parent field now requires hierarchical post type.

See WordPress#15290.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Mamaduka

Copy link
Copy Markdown
Member

Closing in favor of #16187.

@Mamaduka Mamaduka closed this Nov 24, 2026
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.

4 participants