Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compute particular commit order for deletions #9377

Closed
wants to merge 1 commit into from

Conversation

jusephe
Copy link

@jusephe jusephe commented Jan 13, 2022

Fixes: #9376

@jusephe
Copy link
Author

jusephe commented Jan 14, 2022

I just pushed new commit to fix "Static Analysis with Psalm".

lib/Doctrine/ORM/UnitOfWork.php Outdated Show resolved Hide resolved
lib/Doctrine/ORM/UnitOfWork.php Outdated Show resolved Hide resolved
@SenseException
Copy link
Member

It looks like your test does not cover your fix, because when I undo your changes in UnitOfWork, the test doesn't fail. ORM seems to be able to handle the test case.

@jusephe
Copy link
Author

jusephe commented Feb 14, 2022

@SenseException Have you tried with a DB platform supporting foreign key constraints. (i.e., not SQLite)? I tried it again and it still fails...

@jusephe jusephe force-pushed the commit-order-test branch 2 times, most recently from 2d301aa to ff5ce3e Compare April 7, 2022 17:42
@jusephe
Copy link
Author

jusephe commented Apr 7, 2022

@SenseException Can I help you somehow with testing the issue? I rebased my branch onto current version and the test still fails if I undo my changes. The test has to be run with a DB platform supporting foreign key constraints. (i.e., NOT SQLite).

@SenseException
Copy link
Member

Sorry for the late answer and for forgetting about this PR. The commit order calculation isn't an easy topic and I'll have to take more time to review it. I also want to prevent possible impacts on performance.

@SenseException
Copy link
Member

Please change the base branch to 2.12.x and rebase.

@derrabus derrabus changed the base branch from 2.11.x to 2.12.x April 25, 2022 08:59
@jusephe
Copy link
Author

jusephe commented Apr 28, 2022

@SenseException I rebased my branch onto 2.12.x. The test still fails if I undo my changes. (The test has to be run with a DB platform supporting foreign key constraints (i.e., NOT SQLite).

Copy link
Member

@SenseException SenseException left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@doctrine/doctrinecore

lib/Doctrine/ORM/UnitOfWork.php Show resolved Hide resolved
tests/Doctrine/Tests/ORM/Functional/Ticket/GH9376Test.php Outdated Show resolved Hide resolved
@jusephe
Copy link
Author

jusephe commented Oct 11, 2022

@SenseException Can I help you somehow with this PR? I rebased my branch onto 2.13.x and the test still fails if I undo my changes.

This fixes a bug which arises in some cases when trying to delete two entities which have a circular reference through other entities. UnifOfWork computed the order which was not correct for deletions and it failed with ForeignKeyConstraintViolationException. To fix that, this adds a new particular function getCommitOrderForDeletions() to compute the right order. This function is similar to getCommitOrder(), but it operates only with entities set to be deleted. This also adds test for this issue.
@SenseException
Copy link
Member

Thank you for your offer and your patience. There's currently no help required that I know of. We'll come back in case this PR needs changes or maybe new test cases to prevent breaking changes.

mpdude added a commit to mpdude/doctrine2 that referenced this pull request Feb 27, 2023
Co-authored-by: Josef Šupka <josef.supka@gmail.com>
mpdude added a commit to mpdude/doctrine2 that referenced this pull request Feb 27, 2023
Co-authored-by: Josef Šupka <josef.supka@gmail.com>
mpdude added a commit to mpdude/doctrine2 that referenced this pull request Feb 28, 2023
Co-authored-by: Josef Šupka <josef.supka@gmail.com>
mpdude added a commit to mpdude/doctrine2 that referenced this pull request Mar 11, 2023
Co-authored-by: Josef Šupka <josef.supka@gmail.com>
mpdude added a commit to mpdude/doctrine2 that referenced this pull request Mar 11, 2023
Co-authored-by: Josef Šupka <josef.supka@gmail.com>
mpdude added a commit to mpdude/doctrine2 that referenced this pull request May 31, 2023
This is part of the series of issues fixed by doctrine#10547. In particular, the changes from doctrine#10566 were relevant.

See doctrine#9376 for the bug description; doctrine#9377 is obsoleted by doctrine#10547.
mpdude added a commit to mpdude/doctrine2 that referenced this pull request May 31, 2023
This is part of the series of issues fixed by doctrine#10547. In particular, the changes from doctrine#10566 were relevant.

See doctrine#9376 for the bug description; doctrine#9377 is obsoleted by doctrine#10547.
mpdude added a commit to mpdude/doctrine2 that referenced this pull request May 31, 2023
This is part of the series of issues fixed by doctrine#10547. In particular, the changes from doctrine#10566 were relevant.

See doctrine#9376 for the bug description; doctrine#9377 is obsoleted by doctrine#10547.
@mpdude
Copy link
Contributor

mpdude commented May 31, 2023

Also for me, the test case passes on the current 2.16.x branch without further modifications to the UoW. Yes, I am using a DBMS with foreign keys.

Could you please re-check that and/or provide only the failing test in a dedicated PR against 2.16 (and notify me)?

Thanks!

/cc @greg0ire

@mpdude
Copy link
Contributor

mpdude commented Jan 3, 2024

@jusephe are you still interested in working on this? Could you check if the problem is solved by #10913?

@jusephe
Copy link
Author

jusephe commented Jun 19, 2024

@mpdude Hi, sorry for late answer. The problem is fixed either by #10547 or #10913. Thank you very much! I am closing this.

@jusephe jusephe closed this Jun 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Doctrine tries to delete entities in incorrect order
4 participants