Skip to content

Commit f4ab0d6

Browse files
committed
Work around the removal of Connection::connect()
1 parent 17c7185 commit f4ab0d6

File tree

5 files changed

+12
-17
lines changed

5 files changed

+12
-17
lines changed

pkg/dbal/DbalConnectionFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ private function establishConnection(): Connection
8686
{
8787
if (false == $this->connection) {
8888
$this->connection = DriverManager::getConnection($this->config['connection']);
89-
$this->connection->connect();
89+
$this->connection->getServerVersion(); // calls connect() internally
9090
}
9191

9292
return $this->connection;

pkg/dbal/ManagerRegistryConnectionFactory.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,9 @@ public function close(): void
5959

6060
private function establishConnection(): Connection
6161
{
62+
/** @var Connection $connection */
6263
$connection = $this->registry->getConnection($this->config['connection_name']);
63-
$connection->connect();
64+
$connection->getServerVersion(); // calls connect() internally
6465

6566
return $connection;
6667
}

pkg/enqueue-bundle/Consumption/Extension/DoctrinePingConnectionExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function onMessageReceived(MessageReceived $context): void
3636
);
3737

3838
$connection->close();
39-
$connection->connect();
39+
$connection->getServerVersion(); // calls connect() internally
4040

4141
$context->getLogger()->debug(
4242
'[DoctrinePingConnectionExtension] Connection is active now.'

pkg/enqueue-bundle/Tests/Unit/Consumption/Extension/DoctrinePingConnectionExtensionTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function testShouldNotReconnectIfConnectionIsOK()
4343
;
4444
$connection
4545
->expects($this->never())
46-
->method('connect')
46+
->method('getServerVersion')
4747
;
4848

4949
$context = $this->createContext();
@@ -83,7 +83,7 @@ public function testShouldDoesReconnectIfConnectionFailed()
8383
;
8484
$connection
8585
->expects($this->once())
86-
->method('connect')
86+
->method('getServerVersion')
8787
;
8888

8989
$context = $this->createContext();

pkg/job-queue/Test/DbalPersistedConnection.php

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ class DbalPersistedConnection extends Connection
2222
*/
2323
protected static $persistedTransactionNestingLevels;
2424

25-
public function connect()
25+
public function connect(): DriverConnection
2626
{
2727
if ($this->isConnected()) {
28-
return false;
28+
return $this->_conn;
2929
}
3030

3131
if ($this->hasPersistedConnection()) {
@@ -35,28 +35,22 @@ public function connect()
3535
$this->persistConnection($this->_conn);
3636
}
3737

38-
return true;
38+
return $this->_conn;
3939
}
4040

41-
public function beginTransaction()
41+
public function beginTransaction(): void
4242
{
4343
$this->wrapTransactionNestingLevel('beginTransaction');
44-
45-
return true;
4644
}
4745

48-
public function commit()
46+
public function commit(): void
4947
{
5048
$this->wrapTransactionNestingLevel('commit');
51-
52-
return true;
5349
}
5450

55-
public function rollBack()
51+
public function rollBack(): void
5652
{
5753
$this->wrapTransactionNestingLevel('rollBack');
58-
59-
return true;
6054
}
6155

6256
/**

0 commit comments

Comments
 (0)