mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 00:46:50 +02:00
MDL-19470 detection of unfinished transactions and transactions interrupted by exceptions
This commit is contained in:
parent
18e8f3ab9e
commit
1fbdf76ddb
2 changed files with 13 additions and 2 deletions
|
@ -119,7 +119,17 @@ class invalid_state_exception extends moodle_exception {
|
|||
* Default exception handler, uncought exceptions are equivalent to using print_error()
|
||||
*/
|
||||
function default_exception_handler($ex) {
|
||||
global $CFG;
|
||||
global $CFG, $DB, $SCRIPT;
|
||||
|
||||
// detect active db transactions, rollback and log as error
|
||||
if ($DB->is_transaction_started()) {
|
||||
error_log('Database transaction aborted by exception in '.$CFG->dirroot.$SCRIPT);
|
||||
try {
|
||||
// note: transaction blocks should never change current $_SESSION
|
||||
$DB->rollback_sql();
|
||||
} catch (Exception $ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
$backtrace = $ex->getTrace();
|
||||
$place = array('file'=>$ex->getFile(), 'line'=>$ex->getLine(), 'exception'=>get_class($ex));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue