Skip to content

[Tree] Fix TreeObjectHydrator compatibility with ORM 3 - #3041

Open
PhilDaiguille wants to merge 2 commits into
doctrine-extensions:mainfrom
PhilDaiguille:fix/tree-object-hydrator-orm3
Open

[Tree] Fix TreeObjectHydrator compatibility with ORM 3#3041
PhilDaiguille wants to merge 2 commits into
doctrine-extensions:mainfrom
PhilDaiguille:fix/tree-object-hydrator-orm3

Conversation

@PhilDaiguille

@PhilDaiguille PhilDaiguille commented Mar 9, 2026

Copy link
Copy Markdown

Hello ! Fix bug in issue : #2921
This pull request fixes a compatibility issue in the TreeObjectHydrator with ORM 3 when the parent property is defined before the children property in an entity. It also adds a new test fixture and test case to ensure this scenario is properly handled.

Bug fix for ORM 3 compatibility:

  • Updated TreeObjectHydrator to correctly handle association mappings whether they are arrays or objects, ensuring the hydrator works when the parent property is defined before the children property in tree entities.
  • Added a changelog entry describing the fix for TreeObjectHydrator compatibility with ORM 3.

Testing improvements:

  • Added a new fixture entity RootCategoryReversed with the parent property defined before children, to test the fixed scenario.
  • Registered RootCategoryReversed in the test suite and added a test case testFullTreeHydrationWithReversedFieldOrder to verify correct tree hydration when field order is reversed. [1] [2] [3]

@PhilDaiguille
PhilDaiguille force-pushed the fix/tree-object-hydrator-orm3 branch 2 times, most recently from c437c35 to 4a559b0 Compare March 9, 2026 21:53

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.

Pull request overview

Fixes a Doctrine ORM 3 compatibility bug in TreeObjectHydrator when reflection encounters the parent association before the children association, and adds coverage intended to prevent regressions.

Changes:

  • Updated TreeObjectHydrator::getChildrenField() to better handle ORM 3 association mapping objects.
  • Added a new tree fixture (RootCategoryReversed) and a dedicated hydration test for the “reversed field order” scenario.
  • Documented the fix in the Unreleased changelog.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
src/Tree/Hydrator/ORM/TreeObjectHydrator.php Adjusts children-field detection to support ORM 3 mapping objects.
tests/Gedmo/Tree/Fixture/RootCategoryReversed.php Adds a new fixture intended to model the parent/children field-order edge case.
tests/Gedmo/Tree/TreeObjectHydratorTest.php Adds a new test case and registers the new fixture for hydration coverage.
CHANGELOG.md Adds an Unreleased “Fixed” entry describing the ORM 3 compatibility fix.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/Tree/Hydrator/ORM/TreeObjectHydrator.php
Comment thread tests/Gedmo/Tree/Fixture/RootCategoryReversed.php Outdated
…operty order

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

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.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.

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

Labels

Bug A confirmed bug in Extensions that needs fixing. Tree

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants