$defaults = [
'localDomain' => wfWikiID(),
'hostname' => wfHostname(),
+ 'profiler' => Profiler::instance(),
'trxProfiler' => Profiler::instance()->getTransactionProfiler(),
'replLogger' => LoggerFactory::getInstance( 'DBReplication' ),
'queryLogger' => LoggerFactory::getInstance( 'wfLogDBError' ),
/** @var int[] Prior mFlags values */
private $priorFlags = [];
- /** @var Profiler */
+ /** @var object|string Class name or object With profileIn/profileOut methods */
protected $profiler;
/** @var TransactionProfiler */
protected $trxProfiler;
? $params['srvCache']
: new HashBagOStuff();
- $this->profiler = isset( $params['profiler'] )
- ? $params['profiler']
- : Profiler::instance(); // @TODO: remove global state
+ $this->profiler = isset( $params['profiler'] ) ? $params['profiler'] : null;
$this->trxProfiler = isset( $params['trxProfiler'] )
? $params['trxProfiler']
: new TransactionProfiler();
return $this->lazyMasterHandle;
}
- /**
- * @param TransactionProfiler $profiler
- * @since 1.27
- */
- public function setTransactionProfiler( TransactionProfiler $profiler ) {
- $this->trxProfiler = $profiler;
- }
-
public function implicitGroupby() {
return true;
}
$queryProf .= $this->mTrxShortId ? " [TRX#{$this->mTrxShortId}]" : "";
$startTime = microtime( true );
- $this->profiler->profileIn( $queryProf );
+ if ( $this->profiler ) {
+ call_user_func( [ $this->profiler, 'profileIn' ], $queryProf );
+ }
$ret = $this->doQuery( $commentedSql );
- $this->profiler->profileOut( $queryProf );
+ if ( $this->profiler ) {
+ call_user_func( [ $this->profiler, 'profileOut' ], $queryProf );
+ }
$queryRuntime = max( microtime( true ) - $startTime, 0.0 );
unset( $queryProfSection ); // profile out (if set)
abstract class LBFactory {
/** @var ChronologyProtector */
protected $chronProt;
+ /** @var object|string Class name or object With profileIn/profileOut methods */
+ protected $profiler;
/** @var TransactionProfiler */
protected $trxProfiler;
/** @var LoggerInterface */
$this->chronProt = isset( $conf['chronProt'] )
? $conf['chronProt']
: $this->newChronologyProtector();
+
+ $this->profiler = isset( $params['profiler'] ) ? $params['profiler'] : null;
$this->trxProfiler = isset( $conf['trxProfiler'] )
? $conf['trxProfiler']
: new TransactionProfiler();
'readOnlyReason' => $this->readOnlyReason,
'srvCache' => $this->srvCache,
'wanCache' => $this->wanCache,
+ 'profiler' => $this->profiler,
'trxProfiler' => $this->trxProfiler,
'queryLogger' => $this->queryLogger,
'connLogger' => $this->connLogger,
private $memCache;
/** @var WANObjectCache */
private $wanCache;
+ /** @var object|string Class name or object With profileIn/profileOut methods */
+ protected $profiler;
/** @var TransactionProfiler */
protected $trxProfiler;
/** @var LoggerInterface */
} else {
$this->wanCache = WANObjectCache::newEmpty();
}
+ $this->profiler = isset( $params['profiler'] ) ? $params['profiler'] : null;
if ( isset( $params['trxProfiler'] ) ) {
$this->trxProfiler = $params['trxProfiler'];
} else {
// Set loggers
$server['connLogger'] = $this->connLogger;
$server['queryLogger'] = $this->queryLogger;
+ $server['profiler'] = $this->profiler;
$server['trxProfiler'] = $this->trxProfiler;
$server['cliMode'] = $this->cliMode;
$server['errorLogger'] = $this->errorLogger;