8000 bug #44309 [Messenger] Leverage DBAL's getNativeConnection() method (… · symfony/symfony@af596bf · GitHub
[go: up one dir, main page]

Skip to content

Commit af596bf

Browse files
committed
bug #44309 [Messenger] Leverage DBAL's getNativeConnection() method (derrabus)
This PR was merged into the 5.3 branch. Discussion ---------- [Messenger] Leverage DBAL's getNativeConnection() method | Q | A | ------------- | --- | Branch? | 5.3 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | N/A | License | MIT | Doc PR | N/A Doctrine DBAL 3 introduced a new driver middleware system that makes it difficult to unwrap the native PDO connection which we need for Messenger's Postgres transport. If an application would actually make use of the middleware system, accessing the PDO connection would become impossible for us. Because of that, I have added a method `getNativeConnection()` to DBAL with doctrine/dbal#5037. This PR leverages this new method. Commits ------- cde5ec7 Leverage DBAL's getNativeConnection() method
2 parents c19bc94 + cde5ec7 commit af596bf

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/Symfony/Component/Messenger/Bridge/Doctrine/Transport/PostgreSqlConnection.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,13 @@ public function get(): ?array
7373
$this->listening = true;
7474
}
7575

76-
$wrappedConnection = $this->driverConnection->getWrappedConnection();
77-
if (!$wrappedConnection instanceof \PDO && $wrappedConnection instanceof DoctrinePdoConnection) {
78-
$wrappedConnection = $wrappedConnection->getWrappedConnection();
76+
if (method_exists($this->driverConnection, 'getNativeConnection')) {
77+
$wrappedConnection = $this->driverConnection->getNativeConnection();
78+
} else {
79+
$wrappedConnection = $this->driverConnection->getWrappedConnection();
80+
if (!$wrappedConnection instanceof \PDO && $wrappedConnection instanceof DoctrinePdoConnection) {
81+
$wrappedConnection = $wrappedConnection->getWrappedConnection();
82+
}
7983
}
8084

8185
$notification = $wrappedConnection->pgsqlGetNotify(\PDO::FETCH_ASSOC, $this->configuration['get_notify_timeout']);

0 commit comments

Comments
 (0)
0