Use DBAL Driver middleware to handle the correct connection timezone

I looked into using DBAL events for this but found that DBAL events
are deprecated so I went with middleware as they are recommended
as a replacement for the DBAL events.
[MAILPOET-6142]
This commit is contained in:
Rostislav Wolny
2024-08-13 10:36:13 +02:00
committed by Aschepikov
parent 3ea44e45d4
commit 9f32c59e49
4 changed files with 34 additions and 8 deletions

View File

@@ -0,0 +1,14 @@
<?php declare(strict_types = 1);
namespace MailPoet\Doctrine\Middlewares;
use MailPoetVendor\Doctrine\DBAL\Driver\Connection;
use MailPoetVendor\Doctrine\DBAL\Driver\Middleware\AbstractDriverMiddleware;
class PostConnectMiddleware extends AbstractDriverMiddleware {
public function connect(array $params): Connection {
$connection = parent::connect($params);
$connection->exec('SET time_zone = "+00:00"');
return $connection;
}
}