$this->mOpened = false;
if ( $this->mConn ) {
if ( $this->trxLevel() ) {
- if ( $this->mTrxAutomatic ) {
- // clear flag, so commit() doesn't complain about an explicit commit of an implicit transaction.
- $this->mTrxAutomatic = false;
- } else {
+ if ( !$this->mTrxAutomatic ) {
wfWarn( "Transaction still in progress (from {$this->mTrxFname}), " .
" performing implicit commit before closing connection!" );
}
- $this->commit( __METHOD__ );
+ $this->commit( __METHOD__, true );
}
$ret = $this->closeConnection();
* Nesting of transactions is not supported.
*
* @param $fname string
- */
- final public function commit( $fname = 'DatabaseBase::commit' ) {
- if ( !$this->mTrxLevel ) {
- wfWarn( "$fname: No transaction to commit, something got out of sync!" );
- } elseif( $this->mTrxAutomatic ) {
- wfWarn( "$fname: Explicit commit of implicit transaction. Something may be out of sync!" );
+ * @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.
+ */
+ final public function commit( $fname = 'DatabaseBase::commit', $suppressWarnings = false ) {
+ if ( !$suppressWarnings ) {
+ if ( !$this->mTrxLevel ) {
+ wfWarn( "$fname: No transaction to commit, something got out of sync!" );
+ } elseif( $this->mTrxAutomatic ) {
+ wfWarn( "$fname: Explicit commit of implicit transaction. Something may be out of sync!" );
+ }
}
$this->doCommit( $fname );
foreach ( $this->mConns as $conns2 ) {
foreach ( $conns2 as $conns3 ) {
foreach ( $conns3 as $conn ) {
- $conn->commit( __METHOD__ );
+ if ( $conn->trxLevel() ) {
+ $conn->commit( __METHOD__, true );
+ }
}
}
}
}
foreach ( $conns2[$masterIndex] as $conn ) {
if ( $conn->trxLevel() && $conn->doneWrites() ) {
- $conn->commit( __METHOD__ );
+ $conn->commit( __METHOD__, true );
}
}
}