mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
Incorrect subclasses dependencies weight while calculating commit orders #7155
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @sylfabre on GitHub (May 19, 2023).
Bug Report
Summary
The weight of subclasses' dependencies is always 1 while the parent class' dependencies weight comes from the nullable attribute of the join columns.
Current behavior
Parent class and subclasses' dependencies don't have the same weight.
How to reproduce
Imagine this setup with 3 entities
City
Street (can be Street, Boulevard, or Avenue as inheritance mapping)
House
House has a Street (not null)
Street has a City (not null)
City has a main Street (nullable as we have to first insert the City before the Street due to foreign key constraints)
Street has a main House (nullable as we have to first insert the Street before the House due to foreign key constraints)
Expected dependencies are:
Current dependencies are:
This comes from
UnitOfWork::getCommitOrder()which always uses 1 as weight when calling$calc->addDependency()for subclasses (see https://github.com/doctrine/orm/pull/10716 about a suggested fix)Expected behavior
Parent class and subclasses' dependencies have the same weight.
@mpdude commented on GitHub (May 31, 2023):
Hey there 👋🏼,
I am actively working on major changes to the commit order computation. Could you please have a look at #10547 and/or try if the branch
entity-level-commit-order(you can Composer-install it asdev-entity-level-commit-order!) solves the issues for you? If so, please leave a note in #10547.@mpdude commented on GitHub (May 31, 2023):
Can you show where this leads to problems down the road, with the UoW doing things in the wrong order or similar?
@sylfabre commented on GitHub (Jun 1, 2023):
Hello @mpdude
I identified the issue while investigating https://github.com/doctrine/orm/issues/10713 and the fix I'm suggesting for this issue is enough for my use case. I guess the order in which
$calc->addDependency()is called for each entity matters a lot here.So, unfortunately, I wasn't able to identify a problem down the road due to an incorrect calculation that I could reproduce with a functional test 😞
But I'm pretty sure that feeding incorrect data to the calculator will lead to problems (yet to be found) down the road
@sylfabre commented on GitHub (Jul 30, 2023):
This issue will be fixed by https://github.com/doctrine/orm/pull/10547/files
Thanks @mpdude