Description
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)