Skip to content

UnitOfWork::executeUpdates foreach duplicates bug under recursion #11938

Open
@garex

Description

@garex

Bug Report

Q A
Version 2.16.0 till present

Summary

Doctrine ORM v2.16.0 internally starts to execute all updates by single foreach on single UoW property.

Events firing stays inside foreach.

In every iteration property entityUpdates is unsetted. But if we will have recursive call, that will return us to executeUpdates -- then unsetted in later recursive call update will be exceuted on 1st level call.

Current behavior

Duplicated iteration calls and event firing.

Expected behavior

Iteration that respects unsetted entityUpdates from inner recursion level.

How to reproduce

All details, examples and demos are at https://github.com/garex/doctrine-orm-updates-bug

See github actions and unit tests.

Fix also simple:

                foreach ($it = new \ArrayIterator($this->entityUpdates) as $oid => $entity) {
                    // ...
                    unset($it[$oid]); // Unset here also needed
                    unset($this->entities[$oid]);
                    // ...
                }
            }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions