mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 08:56:36 +02:00
Merge branch 'MDL-52284-master' of git://github.com/marinaglancy/moodle
This commit is contained in:
commit
0a57ba06cb
9 changed files with 62 additions and 8 deletions
|
@ -126,6 +126,9 @@ class backp_settings_testcase extends basic_testcase {
|
|||
} catch (exception $e) {
|
||||
$this->assertTrue($e instanceof base_setting_exception);
|
||||
$this->assertEquals($e->errorcode, 'incorrect_object_passed');
|
||||
} catch (TypeError $e) {
|
||||
// On PHP7+ we get a TypeError raised, lets check we've the right error.
|
||||
$this->assertRegexp('/must be an instance of backup_setting_ui/', $e->getMessage());
|
||||
}
|
||||
restore_error_handler();
|
||||
|
||||
|
@ -140,6 +143,9 @@ class backp_settings_testcase extends basic_testcase {
|
|||
} catch (exception $e) {
|
||||
$this->assertTrue($e instanceof base_setting_exception);
|
||||
$this->assertEquals($e->errorcode, 'incorrect_object_passed');
|
||||
} catch (TypeError $e) {
|
||||
// On PHP7+ we get a TypeError raised, lets check we've the right error.
|
||||
$this->assertRegexp('/must be an instance of backup_setting_ui/', $e->getMessage());
|
||||
}
|
||||
restore_error_handler();
|
||||
|
||||
|
@ -302,6 +308,9 @@ class backp_settings_testcase extends basic_testcase {
|
|||
} catch (exception $e) {
|
||||
$this->assertTrue($e instanceof backup_setting_exception);
|
||||
$this->assertEquals($e->errorcode, 'incorrect_object_passed');
|
||||
} catch (TypeError $e) {
|
||||
// On PHP7+ we get a TypeError raised, lets check we've the right error.
|
||||
$this->assertRegexp('/must be an instance of base_setting/', $e->getMessage());
|
||||
}
|
||||
restore_error_handler();
|
||||
|
||||
|
|
|
@ -81,6 +81,9 @@ class core_shutdown_manager {
|
|||
}
|
||||
} catch (Exception $e) {
|
||||
error_log('Exception ignored in shutdown function '.var_export($callback, true).':'.$e->getMessage());
|
||||
} catch (Throwable $e) {
|
||||
// Engine errors in PHP7 throw exceptions of type Throwable (this "catch" will be ignored in PHP5).
|
||||
error_log('Exception ignored in shutdown function '.var_export($callback, true).':'.$e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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 Exception|Throwable $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 Exception|Throwable $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);
|
||||
}
|
||||
|
|
|
@ -88,7 +88,14 @@ abstract class advanced_testcase extends base_testcase {
|
|||
trigger_error('Unexpected debugging() call detected.', E_USER_NOTICE);
|
||||
}
|
||||
|
||||
} catch (Exception $e) {
|
||||
} catch (Exception $ex) {
|
||||
$e = $ex;
|
||||
} catch (Throwable $ex) {
|
||||
// Engine errors in PHP7 throw exceptions of type Throwable (this "catch" will be ignored in PHP5).
|
||||
$e = $ex;
|
||||
}
|
||||
|
||||
if (isset($e)) {
|
||||
// cleanup after failed expectation
|
||||
self::resetAllData();
|
||||
throw $e;
|
||||
|
|
|
@ -62,7 +62,15 @@ abstract class basic_testcase extends base_testcase {
|
|||
|
||||
try {
|
||||
parent::runBare();
|
||||
} catch (Exception $e) {
|
||||
|
||||
} catch (Exception $ex) {
|
||||
$e = $ex;
|
||||
} catch (Throwable $ex) {
|
||||
// Engine errors in PHP7 throw exceptions of type Throwable (this "catch" will be ignored in PHP5).
|
||||
$e = $ex;
|
||||
}
|
||||
|
||||
if (isset($e)) {
|
||||
// cleanup after failed expectation
|
||||
phpunit_util::reset_all_data();
|
||||
throw $e;
|
||||
|
|
|
@ -142,7 +142,14 @@ abstract class database_driver_testcase extends base_testcase {
|
|||
try {
|
||||
parent::runBare();
|
||||
|
||||
} catch (Exception $e) {
|
||||
} catch (Exception $ex) {
|
||||
$e = $ex;
|
||||
} catch (Throwable $ex) {
|
||||
// Engine errors in PHP7 throw exceptions of type Throwable (this "catch" will be ignored in PHP5).
|
||||
$e = $ex;
|
||||
}
|
||||
|
||||
if (isset($e)) {
|
||||
if ($this->tdb->is_transaction_started()) {
|
||||
$this->tdb->force_transaction_rollback();
|
||||
}
|
||||
|
|
|
@ -378,7 +378,14 @@ function default_exception_handler($ex) {
|
|||
$DB->set_debug(0);
|
||||
}
|
||||
echo $OUTPUT->fatal_error($info->message, $info->moreinfourl, $info->link, $info->backtrace, $info->debuginfo);
|
||||
} catch (Exception $out_ex) {
|
||||
} catch (Exception $e) {
|
||||
$out_ex = $e;
|
||||
} catch (Throwable $e) {
|
||||
// Engine errors in PHP7 throw exceptions of type Throwable (this "catch" will be ignored in PHP5).
|
||||
$out_ex = $e;
|
||||
}
|
||||
|
||||
if (isset($out_ex)) {
|
||||
// default exception handler MUST not throw any exceptions!!
|
||||
// the problem here is we do not know if page already started or not, we only know that somebody messed up in outputlib or theme
|
||||
// so we just print at least something instead of "Exception thrown without a stack frame in Unknown on line 0":-(
|
||||
|
|
|
@ -1547,6 +1547,9 @@ function install_core($version, $verbose) {
|
|||
cache_helper::purge_all();
|
||||
} catch (exception $ex) {
|
||||
upgrade_handle_exception($ex);
|
||||
} catch (Throwable $ex) {
|
||||
// Engine errors in PHP7 throw exceptions of type Throwable (this "catch" will be ignored in PHP5).
|
||||
upgrade_handle_exception($ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1617,6 +1620,9 @@ function upgrade_core($version, $verbose) {
|
|||
print_upgrade_part_end('moodle', false, $verbose);
|
||||
} catch (Exception $ex) {
|
||||
upgrade_handle_exception($ex);
|
||||
} catch (Throwable $ex) {
|
||||
// Engine errors in PHP7 throw exceptions of type Throwable (this "catch" will be ignored in PHP5).
|
||||
upgrade_handle_exception($ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1651,6 +1657,9 @@ function upgrade_noncore($verbose) {
|
|||
|
||||
} catch (Exception $ex) {
|
||||
upgrade_handle_exception($ex);
|
||||
} catch (Throwable $ex) {
|
||||
// Engine errors in PHP7 throw exceptions of type Throwable (this "catch" will be ignored in PHP5).
|
||||
upgrade_handle_exception($ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue