From: Aaron Schulz Date: Fri, 9 Feb 2018 19:14:08 +0000 (-0800) Subject: Catch Error exceptions in MediaWiki::run() X-Git-Tag: 1.31.0-rc.0~651 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22auteur_infos%22%2C%22id_auteur=%24connect_id_auteur%22%29%20.%20%22?a=commitdiff_plain;h=12d380b37e1bff0675e007a773b05fa004693f9a;p=lhc%2Fweb%2Fwiklou.git Catch Error exceptions in MediaWiki::run() This avoids triggering other exceptions down the road such as "Got COMMIT while atomic sections FileDeleteForm::doDelete, LocalFile::lockingTransaction are still open". Those would happen in LBFactory::__destruct(), when it tries to commit any dangling transactions (firing attached callbacks too). Just like with the Exception case, the DBs needs to all be rolled back. Also make LoadBalancer::rolbackMasterChanges() rollback any explicit transactions even if they have no pending changes. This clears up the state to avoid later atomic section errors. Change-Id: Ic0b6b12c1edc1eec239f4f048359b3bbb497d3ff --- diff --git a/includes/MediaWiki.php b/includes/MediaWiki.php index 150c72f804..371f2cb4fb 100644 --- a/includes/MediaWiki.php +++ b/includes/MediaWiki.php @@ -548,6 +548,9 @@ class MediaWiki { } } + MWExceptionHandler::handleException( $e ); + } catch ( Error $e ) { + // Type errors and such: at least handle it now and clean up the LBFactory state MWExceptionHandler::handleException( $e ); } diff --git a/includes/libs/rdbms/loadbalancer/LoadBalancer.php b/includes/libs/rdbms/loadbalancer/LoadBalancer.php index d070c1eeb0..ce31078376 100644 --- a/includes/libs/rdbms/loadbalancer/LoadBalancer.php +++ b/includes/libs/rdbms/loadbalancer/LoadBalancer.php @@ -1372,7 +1372,7 @@ class LoadBalancer implements ILoadBalancer { $this->trxRoundId = false; $this->forEachOpenMasterConnection( function ( IDatabase $conn ) use ( $fname, $restore ) { - if ( $conn->writesOrCallbacksPending() ) { + if ( $conn->writesOrCallbacksPending() || $conn->explicitTrxActive() ) { $conn->rollback( $fname, $conn::FLUSHING_ALL_PEERS ); } if ( $restore ) {