X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fcontext%2FRequestContext.php;h=c87798eab089767654c3b38c63362ad5623e55ae;hb=cb68ff02309f090bd297e0a49fc81727c4bd3371;hp=63b4f710c7d686a5a1ed91101f93f0aeb0ed6dec;hpb=6e9b4f0e9ce4ccd6089c18b205065ef7fa077484;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/context/RequestContext.php b/includes/context/RequestContext.php index 63b4f710c7..c87798eab0 100644 --- a/includes/context/RequestContext.php +++ b/includes/context/RequestContext.php @@ -22,7 +22,9 @@ * @file */ +use Liuggio\StatsdClient\Factory\StatsdDataFactory; use MediaWiki\Logger\LoggerFactory; +use MediaWiki\MediaWikiServices; /** * Group all the pieces relevant to the context of a request into one instance @@ -63,11 +65,6 @@ class RequestContext implements IContextSource, MutableContext { */ private $skin; - /** - * @var \Liuggio\StatsdClient\Factory\StatsdDataFactory - */ - private $stats; - /** * @var Timing */ @@ -138,14 +135,12 @@ class RequestContext implements IContextSource, MutableContext { /** * 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(); } /** @@ -167,7 +162,7 @@ class RequestContext implements IContextSource, MutableContext { * * @param Title $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; @@ -496,7 +491,7 @@ class RequestContext implements IContextSource, MutableContext { * 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;