[PR #519] [CLOSED] Bug in UnitOfWork::executeDeletions when at least two entities have to b... #8317

Closed
opened 2026-01-22 15:59:22 +01:00 by admin · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/doctrine/orm/pull/519
Author: @maryo
Created: 11/21/2012
Status: Closed

Base: 2.3Head: 2.3


📝 Commits (1)

  • bf6d36a Bug in UnitOfWork::executeDeletions when at least two entities have to be deleted and a listener listening to postRemove event is attached to them and there is also EntityManager::flush in that listener.

📊 Changes

1 file changed (+1 additions, -1 deletions)

View changed files

📝 lib/Doctrine/ORM/UnitOfWork.php (+1 -1)

📄 Description

Bug in UnitOfWork::executeDeletions.

There is a foreach on line 1012 and dispatchEvent on line 1038.
When at least two entities have to be deleted and a listener listening to postRemove event is attached to them and there is also EntityManager::flush in that listener.

  • EntityManager::remove
  • EntityManager::remove
  • EntityManager::flush
    • UnitOfWork::commit
      • UnitOfWork::executeDeletions
        • BasicEntityPersister::delete // FOR THE FIRST REMOVED ENTITY
          ...
        • EventManager::dispatchEvent
          • PostRemoveListener::postRemove
            • EntityManager::flush
              • UnitOfWork::commit
                • UnitOfWork::executeDeletions
                  • BasicEntityPersister::delete // FOR THE SECOND REMOVED ENTITY
        • BasicEntityPersister::delete // FOR THE SECOND REMOVED ENTITY AGAIN because that foreach operates with array "copies" and that unset on line 1020 in UnitOfWork doesnt affact to the array copy
          • UnitOfWork::getEntityIdentifier // line 2735 - NOTICE, because the entity is already deleted from the array

Tests passed (those tests which are not skipped in my environment).

PHPUnit 3.7.9 by Sebastian Bergmann.

Configuration read from D:\Www\doctrine2\phpunit.xml.dist

.....................SSSSSS.................................. 61 / 1783 ( 3%)
............................................................. 122 / 1783 ( 6%)
......S.....SSSS............................................. 183 / 1783 ( 10%)
......................................................SS..... 244 / 1783 ( 13%)
............................................................. 305 / 1783 ( 17%)
............................................................. 366 / 1783 ( 20%)
......S...................................................... 427 / 1783 ( 23%)
............................................................. 488 / 1783 ( 27%)
....................SSSSSSSSSSSSS...........S................ 549 / 1783 ( 30%)
...........S...S...........S............................S.... 610 / 1783 ( 34%)
............................................................. 671 / 1783 ( 37%)
..............................................SS............. 732 / 1783 ( 41%)
....................S........................................ 793 / 1783 ( 44%)
............................................................. 854 / 1783 ( 47%)
............................................................. 915 / 1783 ( 51%)
............................................................. 976 / 1783 ( 54%)
...........................................................S. 1037 / 1783 ( 58%)
........................................S.................... 1098 / 1783 ( 61%)
............................................................. 1159 / 1783 ( 65%)
............................................................. 1220 / 1783 ( 68%)
............................................................. 1281 / 1783 ( 71%)
............................................................. 1342 / 1783 ( 75%)
............................................................. 1403 / 1783 ( 78%)
............................................................. 1464 / 1783 ( 82%)
............................................................. 1525 / 1783 ( 85%)
............................................................. 1586 / 1783 ( 88%)
............................................................. 1647 / 1783 ( 92%)
................S.............S.............................. 1708 / 1783 ( 95%)
.....................................................

Time: 14 seconds, Memory: 97.75Mb

OK, but incomplete or skipped tests!
Tests: 1761, Assertions: 5932, Skipped: 39.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/doctrine/orm/pull/519 **Author:** [@maryo](https://github.com/maryo) **Created:** 11/21/2012 **Status:** ❌ Closed **Base:** `2.3` ← **Head:** `2.3` --- ### 📝 Commits (1) - [`bf6d36a`](https://github.com/doctrine/orm/commit/bf6d36a6742e9d071563fb9dff97cfb05381575f) Bug in UnitOfWork::executeDeletions when at least two entities have to be deleted and a listener listening to postRemove event is attached to them and there is also EntityManager::flush in that listener. ### 📊 Changes **1 file changed** (+1 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `lib/Doctrine/ORM/UnitOfWork.php` (+1 -1) </details> ### 📄 Description Bug in UnitOfWork::executeDeletions. There is a foreach on line 1012 and dispatchEvent on line 1038. When at least two entities have to be deleted and a listener listening to postRemove event is attached to them and there is also EntityManager::flush in that listener. - EntityManager::remove - EntityManager::remove - EntityManager::flush - UnitOfWork::commit - UnitOfWork::executeDeletions - BasicEntityPersister::delete // FOR THE FIRST REMOVED ENTITY ... - EventManager::dispatchEvent - PostRemoveListener::postRemove - EntityManager::flush - UnitOfWork::commit - UnitOfWork::executeDeletions - BasicEntityPersister::delete // FOR THE SECOND REMOVED ENTITY - BasicEntityPersister::delete // FOR THE SECOND REMOVED ENTITY AGAIN because that foreach operates with array "copies" and that unset on line 1020 in UnitOfWork doesnt affact to the array copy - UnitOfWork::getEntityIdentifier // line 2735 - NOTICE, because the entity is already deleted from the array Tests passed (those tests which are not skipped in my environment). PHPUnit 3.7.9 by Sebastian Bergmann. Configuration read from D:\Www\doctrine2\phpunit.xml.dist .....................SSSSSS.................................. 61 / 1783 ( 3%) ............................................................. 122 / 1783 ( 6%) ......S.....SSSS............................................. 183 / 1783 ( 10%) ......................................................SS..... 244 / 1783 ( 13%) ............................................................. 305 / 1783 ( 17%) ............................................................. 366 / 1783 ( 20%) ......S...................................................... 427 / 1783 ( 23%) ............................................................. 488 / 1783 ( 27%) ....................SSSSSSSSSSSSS...........S................ 549 / 1783 ( 30%) ...........S...S...........S............................S.... 610 / 1783 ( 34%) ............................................................. 671 / 1783 ( 37%) ..............................................SS............. 732 / 1783 ( 41%) ....................S........................................ 793 / 1783 ( 44%) ............................................................. 854 / 1783 ( 47%) ............................................................. 915 / 1783 ( 51%) ............................................................. 976 / 1783 ( 54%) ...........................................................S. 1037 / 1783 ( 58%) ........................................S.................... 1098 / 1783 ( 61%) ............................................................. 1159 / 1783 ( 65%) ............................................................. 1220 / 1783 ( 68%) ............................................................. 1281 / 1783 ( 71%) ............................................................. 1342 / 1783 ( 75%) ............................................................. 1403 / 1783 ( 78%) ............................................................. 1464 / 1783 ( 82%) ............................................................. 1525 / 1783 ( 85%) ............................................................. 1586 / 1783 ( 88%) ............................................................. 1647 / 1783 ( 92%) ................S.............S.............................. 1708 / 1783 ( 95%) ..................................................... Time: 14 seconds, Memory: 97.75Mb OK, but incomplete or skipped tests! Tests: 1761, Assertions: 5932, Skipped: 39. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
admin added the pull-request label 2026-01-22 15:59:22 +01:00
admin closed this issue 2026-01-22 15:59:22 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#8317