MDL-52284 core: compatibility with Exception/Throwable changes in PHP7

This commit is contained in:
Tony Levi 2015-08-03 16:16:03 +09:30 committed by Marina Glancy
parent 0dfcc2541a
commit d74b7e424f
7 changed files with 43 additions and 8 deletions

View file

@ -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);
}

View file

@ -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);
}