From: daniel Date: Tue, 9 Oct 2012 13:34:47 +0000 (+0200) Subject: Fix flush-like commit in DeferredUpdates. X-Git-Tag: 1.31.0-rc.0~22088^2 X-Git-Url: http://git.cyclocoop.org/%24self?a=commitdiff_plain;h=34e6fe188a73f4361b329b3c1eb3772dfe89454b;p=lhc%2Fweb%2Fwiklou.git Fix flush-like commit in DeferredUpdates. In the presence of DBO_TRX, commit() may be used like a "flush". Added a flag to trigger this mode to commit() and changed DeferredUpdates to used the flush mode. Change-Id: I529117618194a2669535f3c5c0fed07588597299 --- diff --git a/includes/DeferredUpdates.php b/includes/DeferredUpdates.php index b4989a6997..716e65c8c3 100644 --- a/includes/DeferredUpdates.php +++ b/includes/DeferredUpdates.php @@ -92,7 +92,7 @@ class DeferredUpdates { $update->doUpdate(); if ( $doCommit && $dbw->trxLevel() ) { - $dbw->commit( __METHOD__ ); + $dbw->commit( __METHOD__, 'flush' ); } } catch ( MWException $e ) { // We don't want exceptions thrown during deferred updates to diff --git a/includes/db/Database.php b/includes/db/Database.php index d703134fed..a942afe065 100644 --- a/includes/db/Database.php +++ b/includes/db/Database.php @@ -758,7 +758,7 @@ abstract class DatabaseBase implements DatabaseType { " performing implicit commit before closing connection!" ); } - $this->commit( __METHOD__, true ); + $this->commit( __METHOD__, 'flush' ); } $ret = $this->closeConnection(); @@ -2980,11 +2980,13 @@ abstract class DatabaseBase implements DatabaseType { * Nesting of transactions is not supported. * * @param $fname string - * @param $suppressWarnings bool Suppress any warnings about open transactions (default_ false). - * Only set this if you are absolutely sure that it is safe to ignore these warnings in your context. + * @param $flush String Flush flag, set to 'flush' to disable warnings about explicitly committing implicit + * transactions, or calling commit when no transaction is in progress. + * This will silently break any ongoing explicit transaction. Only set the flush flag if you are sure + * that it is safe to ignore these warnings in your context. */ - final public function commit( $fname = 'DatabaseBase::commit', $suppressWarnings = false ) { - if ( !$suppressWarnings ) { + final public function commit( $fname = 'DatabaseBase::commit', $flush = '' ) { + if ( $flush != 'flush' ) { if ( !$this->mTrxLevel ) { wfWarn( "$fname: No transaction to commit, something got out of sync!" ); } elseif( $this->mTrxAutomatic ) { diff --git a/includes/db/LoadBalancer.php b/includes/db/LoadBalancer.php index cac70467fb..46d24fc0d4 100644 --- a/includes/db/LoadBalancer.php +++ b/includes/db/LoadBalancer.php @@ -908,7 +908,7 @@ class LoadBalancer { foreach ( $conns2 as $conns3 ) { foreach ( $conns3 as $conn ) { if ( $conn->trxLevel() ) { - $conn->commit( __METHOD__, true ); + $conn->commit( __METHOD__, 'flush' ); } } } @@ -927,7 +927,7 @@ class LoadBalancer { } foreach ( $conns2[$masterIndex] as $conn ) { if ( $conn->trxLevel() && $conn->doneWrites() ) { - $conn->commit( __METHOD__, true ); + $conn->commit( __METHOD__, 'flush' ); } } }