From fe884ac2b2e51ca3f43bd96dea2e1e2d20788f3a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Fri, 30 Sep 2016 12:43:43 +0200 Subject: [PATCH] Pass through Exception code in DatabaseException --- .../lib/system/database/exception/DatabaseException.class.php | 4 ++++ .../exception/DatabaseQueryExecutionException.class.php | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/wcfsetup/install/files/lib/system/database/exception/DatabaseException.class.php b/wcfsetup/install/files/lib/system/database/exception/DatabaseException.class.php index 78b10a0fe1..36a5ae6006 100644 --- a/wcfsetup/install/files/lib/system/database/exception/DatabaseException.class.php +++ b/wcfsetup/install/files/lib/system/database/exception/DatabaseException.class.php @@ -17,5 +17,9 @@ class DatabaseException extends \wcf\system\database\DatabaseException { */ public function __construct($message, \PDOException $previous = null) { \Exception::__construct($message, 0, $previous); + + // we cannot use the constructor's parameter, because of (http://php.net/manual/en/exception.getcode.php): + // > Returns the exception code as integer in Exception but possibly as other type in Exception descendants (for example as string in PDOException). + if ($previous) $this->code = $previous->code; } } diff --git a/wcfsetup/install/files/lib/system/database/exception/DatabaseQueryExecutionException.class.php b/wcfsetup/install/files/lib/system/database/exception/DatabaseQueryExecutionException.class.php index 1ca4618411..92fbf947e8 100644 --- a/wcfsetup/install/files/lib/system/database/exception/DatabaseQueryExecutionException.class.php +++ b/wcfsetup/install/files/lib/system/database/exception/DatabaseQueryExecutionException.class.php @@ -23,7 +23,7 @@ class DatabaseQueryExecutionException extends DatabaseQueryException implements * @inheritDoc */ public function __construct($message, $parameters, \PDOException $previous = null) { - \Exception::__construct($message, 0, $previous); + parent::__construct($message, $previous); $this->parameters = $parameters; } -- 2.20.1