Incorrect subclasses dependencies weight while calculating commit orders #7155

Closed
opened 2026-01-22 15:45:42 +01:00 by admin · 4 comments
Owner

Originally created by @sylfabre on GitHub (May 19, 2023).

Bug Report

Q A
BC Break no
Version 2.15.1

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:

  • from House to Street, Boulevard, and Avenue with weight=0
  • from Street, Boulevard, and Avenue to City with weight=0
  • from City to Street, Boulevard, and Avenue with weight=1
  • from Street, Boulevard, and Avenue to House with weight=1

Current dependencies are:

  • from House to Street, Boulevard, and Avenue with weight=0
  • from Street to City with weight=0
  • from Boulevard and Avenue to City with weight=1 KO
  • from City to Street, Boulevard, and Avenue with weight=1
  • from Street, Boulevard, and Avenue to House with weight=1

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.

Originally created by @sylfabre on GitHub (May 19, 2023). ### Bug Report | Q | A |------------ | ------ | BC Break | no | Version | 2.15.1 #### 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: - from House to Street, Boulevard, and Avenue with weight=0 - from Street, Boulevard, and Avenue to City with weight=0 - from City to Street, Boulevard, and Avenue with weight=1 - from Street, Boulevard, and Avenue to House with weight=1 Current dependencies are: - from House to Street, Boulevard, and Avenue with weight=0 - from Street to City with weight=0 - from Boulevard and Avenue to City with weight=1 KO - from City to Street, Boulevard, and Avenue with weight=1 - from Street, Boulevard, and Avenue to House with weight=1 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.
admin closed this issue 2026-01-22 15:45:42 +01:00
Author
Owner

@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 as dev-entity-level-commit-order!) solves the issues for you? If so, please leave a note in #10547.

@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 as `dev-entity-level-commit-order`!) solves the issues for you? If so, please leave a note in #10547.
Author
Owner

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

@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?
Author
Owner

@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 (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
Author
Owner

@sylfabre commented on GitHub (Jul 30, 2023):

This issue will be fixed by https://github.com/doctrine/orm/pull/10547/files

Thanks @mpdude

@sylfabre commented on GitHub (Jul 30, 2023): This issue will be fixed by https://github.com/doctrine/orm/pull/10547/files Thanks @mpdude
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#7155