Describe the bug
A transaction is created and never terminated if flush throws an error.
To Reproduce
We have the following code snippet:
/**
* @property int $id {primary}
* @property DateTimeImmutable|null $createdAt {default now}
* @property string|null $presenter
* @property string|null $method
* @property string|null $action
* @property string|null $url
* @property string|null $ip
* @property string|null $request
* @property User|null $user {m:1 User, oneSided=true}
*/
class Log extends AbstractEntity {}
function logRequest(): void
{
try {
$log = new Log();
$orm->getRepositoryForEntity($log)->attach($log);
$log->user = $this->getUser()->isLoggedIn() ? (int)$this->getUser()->getId() : null;
$log->createdAt = new DateTimeImmutable();
$log->presenter = $this->getName();
$log->action = $this->getAction();
$log->url = $this->getHttpRequest()->getUrl()->getRelativeUrl();
$log->method = $this->getHttpRequest()->getMethod();
$log->ip = $this->getHttpRequest()->getRemoteAddress();
$log->request = $request ?: null;
$this->orm->persistAndFlush($log);
} catch (\Exception) {
}
}
And a database which does NOT have the request column.
This results in an exception being thrown.
The SQL ONLY RUNS
BEGIN TRANSACTION
Steps to reproduce the behavior. It could include:
- Code which you run
- Definition of entities
- SQL table definitions
- Which SQL queries are executed
Expected behavior
A clear and concise description of what you expected to happen.
Versions::
- Database: [PERCONA DB]
- nextras/orm:v5.0.1
- nextras/dbal:v5.0.7
Describe the bug
A transaction is created and never terminated if flush throws an error.
To Reproduce
We have the following code snippet:
And a database which does NOT have the request column.
This results in an exception being thrown.
The SQL ONLY RUNS
BEGIN TRANSACTIONSteps to reproduce the behavior. It could include:
Expected behavior
A clear and concise description of what you expected to happen.
Versions::