Skip to content

Commit

Permalink
Merge pull request #4086 from morozov/internalize-get-params
Browse files Browse the repository at this point in the history
Mark Connection::getParams() internal
  • Loading branch information
morozov authored Jun 18, 2020
2 parents e1d5934 + d57340d commit 6131db3
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
4 changes: 4 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Upgrade to 2.11

## `Connection::getParams()` has been marked internal

Consumers of the Connection class should not rely on connection parameters stored in the connection object. If needed, they should be obtained from a different source, e.g. application configuration.

## Deprecated `Doctrine\DBAL\Driver::getDatabase()`

- The usage of `Doctrine\DBAL\Driver::getDatabase()` is deprecated. Please use `Doctrine\DBAL\Connection::getDatabase()` instead.
Expand Down
4 changes: 3 additions & 1 deletion lib/Doctrine/DBAL/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,8 @@ public function __construct(
/**
* Gets the parameters used during instantiation.
*
* @internal
*
* @return mixed[]
*/
public function getParams()
Expand Down Expand Up @@ -1199,7 +1201,7 @@ public function executeCacheQuery($query, $params, $types, QueryCacheProfile $qc
throw CacheException::noResultDriverConfigured();
}

$connectionParams = $this->getParams();
$connectionParams = $this->params;
unset($connectionParams['platform']);

[$cacheKey, $realKey] = $qcp->generateCacheKeys($query, $params, $types, $connectionParams);
Expand Down
11 changes: 8 additions & 3 deletions lib/Doctrine/DBAL/Id/TableGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Doctrine\DBAL\Connection;
use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Driver;
use Doctrine\DBAL\DriverManager;
use Doctrine\DBAL\LockMode;
use Throwable;
Expand Down Expand Up @@ -69,12 +70,16 @@ class TableGenerator
*/
public function __construct(Connection $conn, $generatorTableName = 'sequences')
{
$params = $conn->getParams();
if ($params['driver'] === 'pdo_sqlite') {
if ($conn->getDriver() instanceof Driver\PDOSqlite\Driver) {
throw new DBALException('Cannot use TableGenerator with SQLite.');
}

$this->conn = DriverManager::getConnection($params, $conn->getConfiguration(), $conn->getEventManager());
$this->conn = DriverManager::getConnection(
$conn->getParams(),
$conn->getConfiguration(),
$conn->getEventManager()
);

$this->generatorTableName = $generatorTableName;
}

Expand Down

0 comments on commit 6131db3

Please sign in to comment.