* @file
*/
+use MediaWiki\Logger\LoggerFactory;
+
/**
* Group all the pieces relevant to the context of a request into one instance
*/
private $skin;
/**
- * @var StatsdDataFactory
+ * @var \Liuggio\StatsdClient\Factory\StatsdDataFactory
*/
private $stats;
+ /**
+ * @var Timing
+ */
+ private $timing;
+
/**
* @var Config
*/
*/
public function getRequest() {
if ( $this->request === null ) {
- global $wgRequest; # fallback to $wg till we can improve this
- $this->request = $wgRequest;
+ global $wgCommandLineMode;
+ // create the WebRequest object on the fly
+ if ( $wgCommandLineMode ) {
+ $this->request = new FauxRequest( array() );
+ } else {
+ $this->request = new WebRequest();
+ }
}
return $this->request;
*/
public function getStats() {
if ( $this->stats === null ) {
- $config = $this->getConfig();
- $prefix = $config->get( 'StatsdMetricPrefix' )
- ? rtrim( $config->get( 'StatsdMetricPrefix' ), '.' )
- : 'MediaWiki';
+ $prefix = rtrim( $this->getConfig()->get( 'StatsdMetricPrefix' ), '.' );
$this->stats = new BufferingStatsdDataFactory( $prefix );
}
return $this->stats;
}
+ /**
+ * Get the timing object
+ *
+ * @return Timing
+ */
+ public function getTiming() {
+ if ( $this->timing === null ) {
+ $this->timing = new Timing( array(
+ 'logger' => LoggerFactory::getInstance( 'Timing' )
+ ) );
+ }
+ return $this->timing;
+ }
+
/**
* Set the Title object
*
if ( $this->title === null ) {
global $wgTitle; # fallback to $wg till we can improve this
$this->title = $wgTitle;
- wfDebugLog( 'GlobalTitleFail', __METHOD__ . ' called by ' . wfGetAllCallers( 5 ) . ' with no title set.' );
+ wfDebugLog(
+ 'GlobalTitleFail',
+ __METHOD__ . ' called by ' . wfGetAllCallers( 5 ) . ' with no title set.'
+ );
}
return $this->title;
* Get a Message object with context set
* Parameters are the same as wfMessage()
*
+ * @param mixed ...
* @return Message
*/
public function msg() {