Skip to content

Commit 0bb43bb

Browse files
committed
Fix the pdo driver indication; one more place with connect()
1 parent 7d924f3 commit 0bb43bb

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ services:
2929
- STOMP_DSN=stomp://guest:guest@rabbitmq:61613/mqdev
3030
- RABITMQ_STOMP_DSN=stomp+rabbitmq://guest:guest@rabbitmq:61613/mqdev
3131
- RABBITMQ_MANAGMENT_DSN=http://guest:guest@rabbitmq:15672/mqdev
32-
- DOCTRINE_DSN=mysql://root:rootpass@mysql/mqdev
32+
- DOCTRINE_DSN=pdo_mysql://root:rootpass@mysql/mqdev
3333
- DOCTRINE_POSTGRES_DSN=postgres://postgres:pass@postgres/template1
3434
- MYSQL_DSN=mysql://root:rootpass@mysql/mqdev
3535
- POSTGRES_DSN=postgres://postgres:pass@postgres/postgres

pkg/dbal/DbalConnectionFactory.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,16 @@ private function establishConnection(): Connection
8686
{
8787
if (false == $this->connection) {
8888
$this->connection = DriverManager::getConnection($this->config['connection']);
89-
$this->connection->getServerVersion(); // calls connect() internally
89+
if (
90+
method_exists($this->connection, 'connect')
91+
&& (new \ReflectionMethod($this->connection, 'connect'))->isPublic()
92+
) {
93+
// DBAL < 4
94+
$this->connection->connect();
95+
} else {
96+
// DBAL >= 4
97+
$this->connection->getServerVersion(); // calls connect() internally
98+
}
9099
}
91100

92101
return $this->connection;

0 commit comments

Comments
 (0)