Skip to content

Commit

Permalink
Fix travis build instability with MySQL and IBM DB2
Browse files Browse the repository at this point in the history
  • Loading branch information
mmucklo committed Aug 11, 2019
1 parent 9ff47e7 commit bb59695
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 9 deletions.
10 changes: 5 additions & 5 deletions .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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 %*')
}
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/DBAL/Driver/Mysqli/MysqliConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
10 changes: 10 additions & 0 deletions lib/Doctrine/DBAL/Driver/Mysqli/MysqliConnectionException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace Doctrine\DBAL\Driver\Mysqli;

/**
* Exception thrown in case the mysqli driver errors while connecting.
*/
class MysqliConnectionException extends MysqliException
{
}
2 changes: 1 addition & 1 deletion lib/Doctrine/DBAL/Driver/PDOConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function __construct($dsn, $user = null, $password = null, ?array $option
$this->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);
}
}

Expand Down
10 changes: 10 additions & 0 deletions lib/Doctrine/DBAL/Driver/PDOConnectionException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace Doctrine\DBAL\Driver;

/**
* PDOConnectionException is used to distinguish connection failures from regular PDOExceptions.
*/
class PDOConnectionException extends PDOException
{
}
2 changes: 1 addition & 1 deletion tests/continuousphp/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
$file = $_SERVER['argv'][$pos + 1];

register_shutdown_function(static function () use ($file) : void {
$cmd = 'wget https://github.com/scrutinizer-ci/ocular/releases/download/1.5.2/ocular.phar'
$cmd = 'wget https://github.com/scrutinizer-ci/ocular/releases/download/1.6.0/ocular.phar'
. ' && php ocular.phar code-coverage:upload --format=php-clover ' . escapeshellarg($file);

passthru($cmd);
Expand Down
3 changes: 3 additions & 0 deletions tests/travis/install-db2-ibm_db2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ set -ex

echo "Installing extension"
(
# https://travis-ci.community/t/then-sudo-apt-get-update-failed-public-key-is-not-available-no-pubkey-6b05f25d762e3157-in-ubuntu-xenial/1728/12
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 6B05F25D762E3157

# updating APT packages as per support recommendation
sudo apt -y -q update
sudo apt install ksh
Expand Down

0 comments on commit bb59695

Please sign in to comment.