From d5ca9b897d9a899800af3e8453110f443860bd66 Mon Sep 17 00:00:00 2001 From: Benjamin Eberlei Date: Sun, 7 Mar 2021 00:49:38 +0100 Subject: [PATCH] [GH-3554] Trigger deprecation for passing user provided PDO instance. --- lib/Doctrine/DBAL/DriverManager.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/Doctrine/DBAL/DriverManager.php b/lib/Doctrine/DBAL/DriverManager.php index d4f90af796f..95a526b7faa 100644 --- a/lib/Doctrine/DBAL/DriverManager.php +++ b/lib/Doctrine/DBAL/DriverManager.php @@ -10,6 +10,7 @@ use Doctrine\DBAL\Driver\PDO; use Doctrine\DBAL\Driver\SQLAnywhere; use Doctrine\DBAL\Driver\SQLSrv; +use Doctrine\Deprecations\Deprecation; use function array_keys; use function array_merge; @@ -217,6 +218,12 @@ public static function getConnection( } if (isset($params['pdo'])) { + Deprecation::trigger( + 'doctrine/dbal', + 'https://github.com/doctrine/dbal/pull/3554', + 'Passing a user provided PDO instance directly to Doctrine is deprecated.' + ); + $params['pdo']->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); $params['driver'] = 'pdo_' . $params['pdo']->getAttribute(\PDO::ATTR_DRIVER_NAME); }