From c7b55e652cd7ea01228eb0724c801f0f0d931455 Mon Sep 17 00:00:00 2001 From: Georgi <4854116+indjeto@users.noreply.github.com> Date: Tue, 13 Aug 2024 16:03:39 +0300 Subject: [PATCH] Fix for ConnectionMiddleware to support DBAL 3 and DBAL 4 connection interfaces --- composer.json | 3 ++ .../Middleware/ConnectionMiddlewareForV3.php | 35 +++++++++++++++++++ ...ware.php => ConnectionMiddlewareForV4.php} | 2 +- src/aliases.php | 18 ++++++++++ 4 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 src/DBAL/Middleware/ConnectionMiddlewareForV3.php rename src/DBAL/Middleware/{ConnectionMiddleware.php => ConnectionMiddlewareForV4.php} (92%) create mode 100644 src/aliases.php diff --git a/composer.json b/composer.json index 01959bd..e8c009e 100644 --- a/composer.json +++ b/composer.json @@ -31,6 +31,9 @@ "symfony/phpunit-bridge": "^6.4" }, "autoload": { + "files": [ + "src/aliases.php" + ], "psr-4": { "DataDog\\AuditBundle\\": "src" } diff --git a/src/DBAL/Middleware/ConnectionMiddlewareForV3.php b/src/DBAL/Middleware/ConnectionMiddlewareForV3.php new file mode 100644 index 0000000..a9e1926 --- /dev/null +++ b/src/DBAL/Middleware/ConnectionMiddlewareForV3.php @@ -0,0 +1,35 @@ +auditFlushMiddleware->flushHandler !== null) { + ($this->auditFlushMiddleware->flushHandler)(); + $this->auditFlushMiddleware->flushHandler = null; + } + + // Call the parent's commit method + return parent::commit(); + } +} diff --git a/src/DBAL/Middleware/ConnectionMiddleware.php b/src/DBAL/Middleware/ConnectionMiddlewareForV4.php similarity index 92% rename from src/DBAL/Middleware/ConnectionMiddleware.php rename to src/DBAL/Middleware/ConnectionMiddlewareForV4.php index fe26309..52c1f4b 100644 --- a/src/DBAL/Middleware/ConnectionMiddleware.php +++ b/src/DBAL/Middleware/ConnectionMiddlewareForV4.php @@ -6,7 +6,7 @@ use Doctrine\DBAL\Driver\Exception; use Doctrine\DBAL\Driver\Middleware\AbstractConnectionMiddleware; -class ConnectionMiddleware extends AbstractConnectionMiddleware +class ConnectionMiddlewareForV4 extends AbstractConnectionMiddleware { public function __construct( Connection $wrappedConnection, diff --git a/src/aliases.php b/src/aliases.php new file mode 100644 index 0000000..9ea2cba --- /dev/null +++ b/src/aliases.php @@ -0,0 +1,18 @@ +