Opened 12 hours ago
Last modified 8 hours ago
#66428 new defect (bug)
Entity Fields: Do not register the Parent field for non-hierarchical post types
| Reported by: | linewebdigital | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | Awaiting Review |
| Component: | Editor | Version: | trunk |
| Severity: | normal | Keywords: | has-patch has-unit-tests |
| Cc: | Focuses: |
Description
Summary
The server registers the Parent DataForm field for any REST-enabled post type supporting page-attributes, even when the post type is not hierarchical. A flat post type can use page-attributes for ordering without supporting parent-child relationships.
This tracks the PHP backport of https://github.com/WordPress/gutenberg/pull/85679 for the reproduced issue https://github.com/WordPress/gutenberg/issues/85595. The entity-fields feature landed for WordPress 7.2 under #66229; that feature ticket is closed. This report concerns the separate parent-field registration regression, not reopening the feature.
Reproduction
On a development installation containing the server-registered core fields, register a REST-enabled custom post type:
add_action( 'init', static function () { register_post_type( 'flat_book', array( 'public' => true, 'show_in_rest' => true, 'hierarchical' => false, 'supports' => array( 'title', 'editor', 'page-attributes' ), ) ); } );
Open an item of this type in the block editor and inspect its post settings. The Parent control is exposed even though the post type is flat. The same defect is observable in the registered fields returned by the entity-fields API: the parent field is present for flat_book.
Expected: parent is registered only when the type is hierarchical and supports page-attributes. Ordering and page-attributes support remain unchanged. A hierarchical type with that support keeps the Parent field; a type without that support does not get it.
Cause and proposed fix
wp_register_core_post_type_supports_fields() in src/wp-includes/build/scripts/core-fields/index.php currently checks only post_type_supports(). Require is_post_type_hierarchical() as well. Replace the support-only parent dataset in tests/phpunit/tests/entity-fields/wpRegisterCoreFieldCollections.php with all four hierarchy/support combinations.
The prepared PHP runtime file is byte-for-byte identical to the Gutenberg fix. No unrelated entity-fields cleanup, post ordering, supports, persistence or legacy React change is included in this Core port. A corresponding Core PR will be linked after this ticket exists; no Core PR has been submitted yet.
Validation
Local Core base 45552748e4e2252320af7995814df29e91a43897, PHP 8.4.12, PHPUnit 9.6.38, MariaDB 10.11.18:
- Unchanged owning class: 36 tests, 143 assertions passed.
- Failing-first regression: 39 tests, 145 assertions, exactly one failure for the non-hierarchical type with page-attributes before the guard.
- Fixed owning class: 39 tests, 145 assertions passed.
- The complete entity-fields group, including REST, passed 125 tests and 458 assertions in single-site and 125 tests and 458 assertions in multisite.
- Applicable coding standards, PHP syntax and diff checks passed. Existing upstream PHPUnit XML deprecation warning remains. No tests or checks were disabled.
These are actual local results from October 27, 2026, not upstream CI results. The full Core suite and a Core browser smoke test were not run. The original Gutenberg contribution has separate dated browser regression coverage.
Suggested release target: 7.2, subject to maintainer triage. The form remains Awaiting Review; no release assignment is claimed.
Use of AI Tools
Νο
Change History (2)
This ticket was mentioned in PR #15290 on WordPress/wordpress-develop by @linewebdigital.
11 hours ago
#1
- Keywords has-patch has-unit-tests added
#2
@
8 hours ago
CI note for https://github.com/WordPress/wordpress-develop/pull/15290 at 28a3eeb6f41b2a4f80f884eb83a075535cd539eb: Core currently pins Gutenberg cc75a79186fd23e72eb015d594e82f40c6209eb5. The build copies core-fields/index.php from that build over the patched file, restoring the support-only Parent condition.
The build-check diff shows this directly: https://github.com/WordPress/wordpress-develop/actions/runs/41185595854/job/124491771320#step:13:9 . The PHPUnit regression then fails for the non-hierarchical type with page-attributes: https://github.com/WordPress/wordpress-develop/actions/runs/41185595815/job/124491867111#step:23:856 .
The companion Gutenberg fix is https://github.com/WordPress/gutenberg/pull/85679; its backport-changelog now links this actual Core PR. Once that fix lands, Core needs a Gutenberg pin/build containing it so regeneration retains the guard. The focused Core patch and regression test remain intact; no workflow checks or tests were disabled.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Summary
Backports the PHP fix from https://github.com/WordPress/gutenberg/pull/85679 for https://github.com/WordPress/gutenberg/issues/85595.
A non-hierarchical custom post type can support
page-attributesfor 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 andpage-attributesbefore 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
hierarchical => falseandsupports => array( 'title', 'editor', 'page-attributes' ).hierarchical => true: Parent remains available. Withoutpage-attributessupport it should not be registered in either case.npm run test:php -- --group entity-fields, thennpm run test:php -- -c tests/phpunit/multisite.xml --group entity-fields. The new test istest_the_parent_field_requires_hierarchy_and_page_attributesintests/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:page-attributes.entity-fieldsgroup including REST passed 125 tests / 458 assertions in single-site and 125 tests / 458 assertions in multisite.git diff --checkpassed.Suggested milestone: 7.2, subject to maintainer triage; no release assignment is claimed. The Gutenberg backport-changelog entry will reference the actual Core PR number after submission, not a placeholder.
Use of AI Tools