Skip to content

bug: Fixtures are not loaded when autocommit mode is disabled #507

Open
@Crovitche-1623

Description

@Crovitche-1623

Bug Report

Q A
Version 3.7.0

Summary

When the autocommit mode is disabled and save points are enabled, the fixtures cannot be loaded because the wrapInTransaction method from doctrine/orm/src/EntityManager.php begin a transaction without checking first if a transaction is active (which is done automatically when the connection is opened when autocommit is disabled). This is a problem because when save points are enabled because it adds savepoint and the fixtures are therefore never loaded.

Potential solution 1:

If I check if a transaction is active before starting a transaction, it works as expected. E.g. :

    public function wrapInTransaction(callable $func): mixed
    {
        if (!$this->conn->isTransactionActive()) {
            $this->conn->beginTransaction();
        }

        // ...
    }

Potential solution 2:

Create a dedicated EntityManager for migrations with autocommit disabled 😢

Moreover, I think transactions should not be automatically started or commited as I explained here: doctrine/dbal#6258 (comment)

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