Skip to content

Commit

Permalink
[doctrineGH-3554] Trigger deprecation for passing user provided PDO i…
Browse files Browse the repository at this point in the history
…nstance.
  • Loading branch information
beberlei committed Mar 11, 2021
1 parent fc78e4f commit 530df9e
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/Doctrine/DBAL/DriverManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 530df9e

Please sign in to comment.