* @file
*/
+use Liuggio\StatsdClient\Factory\StatsdDataFactory;
use MediaWiki\Logger\LoggerFactory;
+use MediaWiki\MediaWikiServices;
+use Wikimedia\ScopedCallback;
/**
* Group all the pieces relevant to the context of a request into one instance
*/
private $skin;
- /**
- * @var \Liuggio\StatsdClient\Factory\StatsdDataFactory
- */
- private $stats;
-
/**
* @var Timing
*/
if ( $this->config === null ) {
// @todo In the future, we could move this to WebStart.php so
// the Config object is ready for when initialization happens
- $this->config = ConfigFactory::getDefaultInstance()->makeConfig( 'main' );
+ $this->config = MediaWikiServices::getInstance()->getMainConfig();
}
return $this->config;
/**
* Get the Stats object
*
- * @return BufferingStatsdDataFactory
+ * @deprecated since 1.27 use a StatsdDataFactory from MediaWikiServices (preferably injected)
+ *
+ * @return StatsdDataFactory
*/
public function getStats() {
- if ( $this->stats === null ) {
- $prefix = rtrim( $this->getConfig()->get( 'StatsdMetricPrefix' ), '.' );
- $this->stats = new BufferingStatsdDataFactory( $prefix );
- }
- return $this->stats;
+ return MediaWikiServices::getInstance()->getStatsdDataFactory();
}
/**
/**
* Set the Title object
*
- * @param Title $title
+ * @param Title|null $title
*/
- public function setTitle( Title $title ) {
+ public function setTitle( Title $title = null ) {
$this->title = $title;
// Erase the WikiPage so a new one with the new title gets created.
$this->wikipage = null;
* Resets singleton returned by getMain(). Should be called only from unit tests.
*/
public static function resetMain() {
- if ( !defined( 'MW_PHPUNIT_TEST' ) ) {
+ if ( !( defined( 'MW_PHPUNIT_TEST' ) || defined( 'MW_PARSER_TEST' ) ) ) {
throw new MWException( __METHOD__ . '() should be called only from unit tests!' );
}
self::$instance = null;