mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 00:46:50 +02:00
MDL-52284 core: compatibility with Exception/Throwable changes in PHP7
This commit is contained in:
parent
0dfcc2541a
commit
d74b7e424f
7 changed files with 43 additions and 8 deletions
|
@ -2431,10 +2431,14 @@ abstract class moodle_database {
|
|||
* automatically if exceptions not caught.
|
||||
*
|
||||
* @param moodle_transaction $transaction An instance of a moodle_transaction.
|
||||
* @param Exception $e The related exception to this transaction rollback.
|
||||
* @param $e The related exception/throwable to this transaction rollback.
|
||||
* @return void This does not return, instead the exception passed in will be rethrown.
|
||||
*/
|
||||
public function rollback_delegated_transaction(moodle_transaction $transaction, Exception $e) {
|
||||
public function rollback_delegated_transaction(moodle_transaction $transaction, $e) {
|
||||
if (!($e instanceof Exception) && !($e instanceof Throwable)) {
|
||||
// PHP7 - we catch Throwables in phpunit but can't use that as the type hint in PHP5.
|
||||
$e = new \coding_exception("Must be given an Exception or Throwable object!");
|
||||
}
|
||||
if ($transaction->is_disposed()) {
|
||||
throw new dml_transaction_exception('Transactions already disposed', $transaction);
|
||||
}
|
||||
|
|
|
@ -95,10 +95,10 @@ class moodle_transaction {
|
|||
/**
|
||||
* Rollback all current delegated transactions.
|
||||
*
|
||||
* @param Exception $e mandatory exception
|
||||
* @param $e mandatory exception/throwable
|
||||
* @return void
|
||||
*/
|
||||
public function rollback(Exception $e) {
|
||||
public function rollback($e) {
|
||||
if ($this->is_disposed()) {
|
||||
throw new dml_transaction_exception('Transactions already disposed', $this);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue