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 MySQL build problems with ConnectionException detection #3656

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
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,7 +90,14 @@ 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':
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
{
}