Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement QueryFailed and ParameterCountMismatch exceptions
These changes are quite invasive towards the database support in MantisBT. A number of legacy error reporting and handling functions specific to database handling have been removed. Legacy database backends (those not using PDO) can be implemented so that they throw their own exceptions in the same way PDO does. This moves responsibility over getLastError() type functions into the legacy backends where it belongs.
- Loading branch information
1 parent
c534116
commit a815cc7
Showing
9 changed files
with
115 additions
and
140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
application/MantisBT/Exception/Database/ParameterCountMismatch.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
namespace MantisBT\Exception\Database; | ||
use MantisBT\Exception\ExceptionAbstract; | ||
|
||
require_api('lang_api.php'); | ||
|
||
class ParameterCountMismatch extends ExceptionAbstract { | ||
public function __construct($queryString, array $parameters) { | ||
$expectedParameterCount = substr_count($queryString, '?'); | ||
$actualParameterCount = count($parameters); | ||
/* TODO: add new language string */ | ||
$errorMessage = lang_get(ERROR_GENERIC, null, false); | ||
$errorMessage = sprintf($errorMessage, $expectedParameterCount, $actualParameterCount, $queryString); | ||
/* TODO: assign new error code instead of 0 */ | ||
parent::__construct(0, $errorMessage, null); | ||
$this->responseCode = 500; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
namespace MantisBT\Exception\Database; | ||
use MantisBT\Exception\ExceptionAbstract; | ||
|
||
require_api('lang_api.php'); | ||
|
||
class QueryFailed extends ExceptionAbstract { | ||
public function __construct($queryErrorCode, $queryErrorDescription, $queryString) { | ||
$errorMessage = lang_get(ERROR_DB_QUERY_FAILED, null, false); | ||
$errorMessage = sprintf($errorMessage, $queryErrorCode, $queryErrorDescription, $queryString); | ||
parent::__construct(ERROR_DB_QUERY_FAILED, $errorMessage, null); | ||
$this->responseCode = 500; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.