Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix travis build instability with MySQL and IBM DB2 #3650

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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