From 4b445ae71d9c0d4ab82641e79a3cd28d55186c1e Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Fri, 26 Jun 2020 20:02:38 -0700 Subject: [PATCH] Deprecate ExceptionConverterDriver --- UPGRADE.md | 4 ++++ lib/Doctrine/DBAL/Driver/AbstractDB2Driver.php | 12 ++++++++++++ lib/Doctrine/DBAL/Driver/AbstractSQLServerDriver.php | 12 ++++++++++++ .../DBAL/Driver/ExceptionConverterDriver.php | 3 +++ phpcs.xml.dist | 5 +++++ 5 files changed, 36 insertions(+) diff --git a/UPGRADE.md b/UPGRADE.md index 34448db1a80..20c6fedd97f 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,9 @@ # Upgrade to 2.11 +## The `ExceptionConverterDriver` interface is deprecated + +All drivers will have to implement the exception conversion API. + ## `DriverException::getErrorCode()` is deprecated The `DriverException::getErrorCode()` is deprecated as redundant and inconsistently supported by drivers. Use `::getCode()` or `::getSQLState()` instead. diff --git a/lib/Doctrine/DBAL/Driver/AbstractDB2Driver.php b/lib/Doctrine/DBAL/Driver/AbstractDB2Driver.php index cede8da7eb0..376672d0a32 100644 --- a/lib/Doctrine/DBAL/Driver/AbstractDB2Driver.php +++ b/lib/Doctrine/DBAL/Driver/AbstractDB2Driver.php @@ -4,6 +4,8 @@ use Doctrine\DBAL\Connection; use Doctrine\DBAL\Driver; +use Doctrine\DBAL\Driver\DriverException as TheDriverException; +use Doctrine\DBAL\Exception\DriverException; use Doctrine\DBAL\Platforms\DB2Platform; use Doctrine\DBAL\Schema\DB2SchemaManager; @@ -39,4 +41,14 @@ public function getSchemaManager(Connection $conn) { return new DB2SchemaManager($conn); } + + /** + * @param string $message + * + * @return DriverException + */ + public function convertException($message, TheDriverException $exception) + { + return new DriverException($message, $exception); + } } diff --git a/lib/Doctrine/DBAL/Driver/AbstractSQLServerDriver.php b/lib/Doctrine/DBAL/Driver/AbstractSQLServerDriver.php index 1fd705a856f..073a40ad13c 100644 --- a/lib/Doctrine/DBAL/Driver/AbstractSQLServerDriver.php +++ b/lib/Doctrine/DBAL/Driver/AbstractSQLServerDriver.php @@ -5,6 +5,8 @@ use Doctrine\DBAL\Connection; use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Driver; +use Doctrine\DBAL\Driver\DriverException as TheDriverException; +use Doctrine\DBAL\Exception\DriverException; use Doctrine\DBAL\Platforms\SQLServer2005Platform; use Doctrine\DBAL\Platforms\SQLServer2008Platform; use Doctrine\DBAL\Platforms\SQLServer2012Platform; @@ -92,4 +94,14 @@ public function getSchemaManager(Connection $conn) { return new SQLServerSchemaManager($conn); } + + /** + * @param string $message + * + * @return DriverException + */ + public function convertException($message, TheDriverException $exception) + { + return new DriverException($message, $exception); + } } diff --git a/lib/Doctrine/DBAL/Driver/ExceptionConverterDriver.php b/lib/Doctrine/DBAL/Driver/ExceptionConverterDriver.php index 959ec4c0659..7137fcf3aa2 100644 --- a/lib/Doctrine/DBAL/Driver/ExceptionConverterDriver.php +++ b/lib/Doctrine/DBAL/Driver/ExceptionConverterDriver.php @@ -2,11 +2,14 @@ namespace Doctrine\DBAL\Driver; +use Doctrine\DBAL\Driver; use Doctrine\DBAL\Driver\DriverException as TheDriverException; use Doctrine\DBAL\Exception\DriverException; /** * Contract for a driver that is capable of converting DBAL driver exceptions into standardized DBAL driver exceptions. + * + * @deprecated All implementors of the {@link Driver} interface will have to implement this API. */ interface ExceptionConverterDriver { diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 3001de2f6bd..83965949b5d 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -100,6 +100,11 @@ lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvStatement.php + + + lib/Doctrine/DBAL/Driver/ExceptionConverterDriver.php + + tests/Doctrine/Tests/DBAL/Functional/Driver/IBMDB2/StatementTest.php