Skip to content

Deprecate driver exception conversion APIs #4137

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

Merged
Merged
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: 6 additions & 4 deletions UPGRADE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Upgrade to 2.11

## Deprecations in driver-level exception handling

1. The `ExceptionConverterDriver` interface and the usage of the `convertException()` method on the `Driver` objects are deprecated.
2. The `driverException()` and `driverExceptionDuringQuery()` factory methods of the `DBALException` class are deprecated.
3. Relying on the wrapper layer handling non-driver exceptions is deprecated.

## `DBALException` factory method deprecations

1. `DBALException::invalidPlatformType()` is deprecated as unused as of v2.7.0.
Expand All @@ -21,10 +27,6 @@ The driver and wrapper statement objects can be only created by the correspondin

The wrapper connection will automatically handle the lost connection if the driver supports reporting it.

## 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.
Expand Down
4 changes: 4 additions & 0 deletions lib/Doctrine/DBAL/DBALException.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ public static function unknownDriver($unknownDriverName, array $knownDrivers)
}

/**
* @deprecated
*
* @param string $sql
* @param mixed[] $params
*
Expand All @@ -157,6 +159,8 @@ public static function driverExceptionDuringQuery(Driver $driver, Throwable $dri
}

/**
* @deprecated
*
* @return self
*/
public static function driverException(Driver $driver, Throwable $driverEx)
Expand Down
2 changes: 2 additions & 0 deletions lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ abstract class AbstractMySQLDriver implements Driver, ExceptionConverterDriver,
/**
* {@inheritdoc}
*
* @deprecated
*
* @link https://dev.mysql.com/doc/refman/8.0/en/client-error-reference.html
* @link https://dev.mysql.com/doc/refman/8.0/en/server-error-reference.html
*/
Expand Down
2 changes: 2 additions & 0 deletions lib/Doctrine/DBAL/Driver/AbstractOracleDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ abstract class AbstractOracleDriver implements Driver, ExceptionConverterDriver
{
/**
* {@inheritdoc}
*
* @deprecated
*/
public function convertException($message, DeprecatedDriverException $exception)
{
Expand Down
2 changes: 2 additions & 0 deletions lib/Doctrine/DBAL/Driver/AbstractPostgreSQLDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ abstract class AbstractPostgreSQLDriver implements Driver, ExceptionConverterDri
/**
* {@inheritdoc}
*
* @deprecated
*
* @link http://www.postgresql.org/docs/9.3/static/errcodes-appendix.html
*/
public function convertException($message, DeprecatedDriverException $exception)
Expand Down
2 changes: 2 additions & 0 deletions lib/Doctrine/DBAL/Driver/AbstractSQLAnywhereDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ abstract class AbstractSQLAnywhereDriver implements Driver, ExceptionConverterDr
/**
* {@inheritdoc}
*
* @deprecated
*
* @link http://dcx.sybase.com/index.html#sa160/en/saerrors/sqlerror.html
*/
public function convertException($message, DeprecatedDriverException $exception)
Expand Down
2 changes: 2 additions & 0 deletions lib/Doctrine/DBAL/Driver/AbstractSQLiteDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ abstract class AbstractSQLiteDriver implements Driver, ExceptionConverterDriver
/**
* {@inheritdoc}
*
* @deprecated
*
* @link http://www.sqlite.org/c3ref/c_abort.html
*/
public function convertException($message, DeprecatedDriverException $exception)
Expand Down
5 changes: 3 additions & 2 deletions lib/Doctrine/DBAL/Driver/ExceptionConverterDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@

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.
* @deprecated
*/
interface ExceptionConverterDriver
{
Expand All @@ -19,6 +18,8 @@ interface ExceptionConverterDriver
* It evaluates the vendor specific error code and SQLSTATE and transforms
* it into a unified {@link DriverException} subclass.
*
* @deprecated
*
* @param string $message The DBAL exception message to use.
* @param TheDriverException $exception The DBAL driver exception to convert.
*
Expand Down