diff --git a/UPGRADE.md b/UPGRADE.md index 8dbab7d54a3..3e2192c8d31 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -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. diff --git a/lib/Doctrine/DBAL/Connection.php b/lib/Doctrine/DBAL/Connection.php index 0a0c8c40d99..55ee3412eda 100644 --- a/lib/Doctrine/DBAL/Connection.php +++ b/lib/Doctrine/DBAL/Connection.php @@ -225,6 +225,8 @@ public function __construct( /** * Gets the parameters used during instantiation. * + * @internal + * * @return mixed[] */ public function getParams() @@ -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); diff --git a/lib/Doctrine/DBAL/Id/TableGenerator.php b/lib/Doctrine/DBAL/Id/TableGenerator.php index 35cda11431b..6b5a62353a4 100644 --- a/lib/Doctrine/DBAL/Id/TableGenerator.php +++ b/lib/Doctrine/DBAL/Id/TableGenerator.php @@ -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; @@ -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; }