Remve usage of RequestContext::getStats()

Bug: T156810
Change-Id: I571aa4afed577e10be8b417cf1a3bf134a130739
This commit is contained in:
Florian Schmidt 2017-04-17 16:55:55 +02:00 committed by Florianschmidtwelzow
parent 7f87f3bca5
commit b598cf35ae

View file

@ -218,7 +218,16 @@ class ScribuntoHooks {
static $stats;
if ( !$stats ) {
$stats = RequestContext::getMain()->getStats();
// check, if MediaWikiServices exists and has a StatsdDataFactory service for
// backward-compatibility with MediaWiki 1.25+
if (
class_exists( 'MediaWiki\\MediaWikiServices' ) &&
\MediaWiki\MediaWikiServices::getInstance()->hasService( 'StatsdDataFactory' )
) {
$stats = \MediaWiki\MediaWikiServices::getInstance()->getStatsdDataFactory();
} else {
$stats = RequestContext::getMain()->getStats();
}
}
$metricKey = sprintf( 'scribunto.traces.%s__%s__%s', wfWikiId(), $moduleName, $functionName );