*/
protected $allViews = null;
+ /** @var TransactionProfiler */
+ protected $trxProfiler;
+
/**
* A string describing the current software version, and possibly
* other details in a user-friendly way. Will be listed on Special:Version, etc.
public function setFakeMaster( $enabled = true ) {
}
+ /**
+ * @return TransactionProfiler
+ */
+ protected function getTransactionProfiler() {
+ return $this->trxProfiler
+ ? $this->trxProfiler
+ : Profiler::instance()->getTransactionProfiler();
+ }
+
/**
* Returns true if this database supports (and uses) cascading deletes
*
$this->mForeign = $foreign;
+ if ( isset( $params['trxProfiler'] ) ) {
+ $this->trxProfiler = $params['trxProfiler']; // override
+ }
+
if ( $user ) {
$this->open( $server, $user, $password, $dbName );
}
$isMaster = !is_null( $this->getLBInfo( 'master' ) );
- $trxProf = Profiler::instance()->getTransactionProfiler();
+ $trxProf = $this->getTransactionProfiler();
$trxProf->recordConnection( $this->mServer, $this->mDBname, $isMaster );
}
# Keep track of whether the transaction has write queries pending
if ( $this->mTrxLevel && !$this->mTrxDoneWrites && $isWriteQuery ) {
$this->mTrxDoneWrites = true;
- Profiler::instance()->getTransactionProfiler()->transactionWritingIn(
+ $this->getTransactionProfiler()->transactionWritingIn(
$this->mServer, $this->mDBname, $this->mTrxShortId );
}
$startTime = microtime( true );
$ret = $this->doQuery( $commentedSql );
# Log the query time and feed it into the DB trx profiler
- $profiler->getTransactionProfiler()->recordQueryCompletion(
+ $this->getTransactionProfiler()->recordQueryCompletion(
$queryProf, $startTime, $isWriteQuery, $this->affectedRows() );
MWDebug::queryTime( $queryId );
$startTime = microtime( true );
$ret = $this->doQuery( $commentedSql );
# Log the query time and feed it into the DB trx profiler
- $profiler->getTransactionProfiler()->recordQueryCompletion(
+ $this->getTransactionProfiler()->recordQueryCompletion(
$queryProf, $startTime, $isWriteQuery, $this->affectedRows() );
}
} else {
$this->runOnTransactionPreCommitCallbacks();
$this->doCommit( $fname );
if ( $this->mTrxDoneWrites ) {
- Profiler::instance()->getTransactionProfiler()->transactionWritingOut(
+ $this->getTransactionProfiler()->transactionWritingOut(
$this->mServer, $this->mDBname, $this->mTrxShortId );
}
$this->runOnTransactionIdleCallbacks();
$this->runOnTransactionPreCommitCallbacks();
$this->doCommit( $fname );
if ( $this->mTrxDoneWrites ) {
- Profiler::instance()->getTransactionProfiler()->transactionWritingOut(
+ $this->getTransactionProfiler()->transactionWritingOut(
$this->mServer, $this->mDBname, $this->mTrxShortId );
}
$this->runOnTransactionIdleCallbacks();
$this->mTrxPreCommitCallbacks = array(); // cancel
$this->mTrxAtomicLevels = new SplStack;
if ( $this->mTrxDoneWrites ) {
- Profiler::instance()->getTransactionProfiler()->transactionWritingOut(
+ $this->getTransactionProfiler()->transactionWritingOut(
$this->mServer, $this->mDBname, $this->mTrxShortId );
}
}