*/
private $mTrxWriteDuration = 0.0;
+ /** @var IDatabase|null Lazy handle to the master DB this server replicates from */
+ private $lazyMasterHandle;
+
/**
* @since 1.21
* @var resource File handle for upgrade
}
}
+ /**
+ * Set a lazy-connecting DB handle to the master DB (for replication status purposes)
+ *
+ * @param IDatabase $conn
+ * @since 1.27
+ */
+ public function setLazyMasterHandle( IDatabase $conn ) {
+ $this->lazyMasterHandle = $conn;
+ }
+
+ /**
+ * @return IDatabase|null
+ * @see setLazyMasterHandle()
+ * @since 1.27
+ */
+ public function getLazyMasterHandle() {
+ return $this->lazyMasterHandle;
+ }
+
/**
* @return TransactionProfiler
*/
list( $phpCallback ) = $callback;
$this->clearFlag( DBO_TRX ); // make each query its own transaction
call_user_func( $phpCallback );
- $this->setFlag( $autoTrx ? DBO_TRX : 0 ); // restore automatic begin()
+ if ( $autoTrx ) {
+ $this->setFlag( DBO_TRX ); // restore automatic begin()
+ } else {
+ $this->clearFlag( DBO_TRX ); // restore auto-commit
+ }
} catch ( Exception $e ) {
if ( $ePrior ) {
MWExceptionHandler::logException( $ePrior );
}
}
+ final public function doAtomicSection( $fname, $callback ) {
+ if ( !is_callable( $callback ) ) {
+ throw new UnexpectedValueException( "Invalid callback." );
+ };
+
+ $this->startAtomic( $fname );
+ try {
+ call_user_func_array( $callback, array( $this, $fname ) );
+ } catch ( Exception $e ) {
+ $this->rollback( $fname );
+ throw $e;
+ }
+ $this->endAtomic( $fname );
+ }
+
/**
* Begin a transaction. If a transaction is already in progress,
* that transaction will be committed before the new transaction is started.