diff --git a/.appveyor.yml b/.appveyor.yml index 63a9c0ddb73..4e0b54d3269 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -22,21 +22,21 @@ environment: driver: sqlsrv db_version: sql2008r2sp2 coverage: yes - php: 7.2 + php: 7.3 - db: mssql driver: sqlsrv db_version: sql2012sp1 - php: 7.2 + php: 7.3 coverage: yes - db: mssql driver: sqlsrv db_version: sql2017 coverage: no - php: 7.2 + php: 7.3 - db: mssql driver: pdo_sqlsrv db_version: sql2017 - php: 7.2 + php: 7.3 coverage: yes init: @@ -103,7 +103,7 @@ install: New-Item -path c:\tools -name ocular -itemtype directory } if (!(Test-Path c:\tools\ocular\ocular.phar)) { - appveyor-retry appveyor DownloadFile https://github.com/scrutinizer-ci/ocular/releases/download/1.5.2/ocular.phar -Filename C:\tools\ocular\ocular.phar + appveyor-retry appveyor DownloadFile https://github.com/scrutinizer-ci/ocular/releases/download/1.6.0/ocular.phar -Filename C:\tools\ocular\ocular.phar Set-Content -path 'C:\tools\ocular\ocular.bat' -Value ('@php C:\tools\ocular\ocular.phar %*') } diff --git a/.travis.yml b/.travis.yml index e0d87665991..48a718a0329 100644 --- a/.travis.yml +++ b/.travis.yml @@ -32,7 +32,7 @@ script: after_script: - | if [ "x$COVERAGE" == "xyes" ]; then - travis_retry wget https://github.com/scrutinizer-ci/ocular/releases/download/1.5.2/ocular.phar + travis_retry wget https://github.com/scrutinizer-ci/ocular/releases/download/1.6.0/ocular.phar travis_retry php ocular.phar code-coverage:upload --format=php-clover clover.xml fi diff --git a/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php b/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php index c46ddc63dd7..a98c0de9e54 100644 --- a/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php +++ b/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php @@ -90,8 +90,15 @@ public function convertException($message, DriverException $exception) case '1429': case '2002': case '2005': + case '2054': return new Exception\ConnectionException($message, $exception); + case '2006': + if ($exception instanceof Driver\Mysqli\MysqliConnectionException || $exception instanceof PDOConnectionException) { + return new Exception\ConnectionException($message, $exception); + } + break; + case '1048': case '1121': case '1138': diff --git a/lib/Doctrine/DBAL/Driver/Mysqli/MysqliConnection.php b/lib/Doctrine/DBAL/Driver/Mysqli/MysqliConnection.php index 1f1a1d218c3..871755702e6 100644 --- a/lib/Doctrine/DBAL/Driver/Mysqli/MysqliConnection.php +++ b/lib/Doctrine/DBAL/Driver/Mysqli/MysqliConnection.php @@ -68,7 +68,7 @@ public function __construct(array $params, $username, $password, array $driverOp }); try { if (! $this->conn->real_connect($params['host'], $username, $password, $dbname, $port, $socket, $flags)) { - throw new MysqliException($this->conn->connect_error, $this->conn->sqlstate ?? 'HY000', $this->conn->connect_errno); + throw new MysqliConnectionException($this->conn->connect_error, $this->conn->sqlstate ?? 'HY000', $this->conn->connect_errno); } } finally { restore_error_handler(); diff --git a/lib/Doctrine/DBAL/Driver/Mysqli/MysqliConnectionException.php b/lib/Doctrine/DBAL/Driver/Mysqli/MysqliConnectionException.php new file mode 100644 index 00000000000..bd26b739ea3 --- /dev/null +++ b/lib/Doctrine/DBAL/Driver/Mysqli/MysqliConnectionException.php @@ -0,0 +1,10 @@ +setAttribute(PDO::ATTR_STATEMENT_CLASS, [PDOStatement::class, []]); $this->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } catch (\PDOException $exception) { - throw new PDOException($exception); + throw new PDOConnectionException($exception); } } diff --git a/lib/Doctrine/DBAL/Driver/PDOConnectionException.php b/lib/Doctrine/DBAL/Driver/PDOConnectionException.php new file mode 100644 index 00000000000..61de97d103f --- /dev/null +++ b/lib/Doctrine/DBAL/Driver/PDOConnectionException.php @@ -0,0 +1,10 @@ +