$this->trxIdleCallbacks = []; // consumed (and recursion guard)
$this->trxEndCallbacks = []; // consumed (recursion guard)
foreach ( $callbacks as $callback ) {
+ ++$count;
+ list( $phpCallback ) = $callback;
+ $this->clearFlag( self::DBO_TRX ); // make each query its own transaction
try {
- ++$count;
- list( $phpCallback ) = $callback;
- $this->clearFlag( self::DBO_TRX ); // make each query its own transaction
call_user_func( $phpCallback, $trigger, $this );
- if ( $autoTrx ) {
- $this->setFlag( self::DBO_TRX ); // restore automatic begin()
- } else {
- $this->clearFlag( self::DBO_TRX ); // restore auto-commit
- }
} catch ( Exception $ex ) {
call_user_func( $this->errorLogger, $ex );
$e = $e ?: $ex;
if ( $this->trxLevel() ) {
$this->rollback( __METHOD__, self::FLUSHING_INTERNAL );
}
+ } finally {
+ if ( $autoTrx ) {
+ $this->setFlag( self::DBO_TRX ); // restore automatic begin()
+ } else {
+ $this->clearFlag( self::DBO_TRX ); // restore auto-commit
+ }
}
}
} while ( count( $this->trxIdleCallbacks ) );
$lbFactory->commitMasterChanges( __METHOD__ );
$this->assertFalse( $called, 'Not called in next round commit' );
+
+ $db->setFlag( DBO_TRX );
+ try {
+ $db->onTransactionCommitOrIdle( function () {
+ throw new RuntimeException( 'test' );
+ } );
+ $this->fail( "Exception not thrown" );
+ } catch ( RuntimeException $e ) {
+ $this->assertTrue( $db->getFlag( DBO_TRX ) );
+ }
}
/**