jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/348466 )

Change subject: Remve usage of RequestContext::getStats()
......................................................................


Remve usage of RequestContext::getStats()

Bug: T156810
Change-Id: I571aa4afed577e10be8b417cf1a3bf134a130739
---
M common/Hooks.php
1 file changed, 10 insertions(+), 1 deletion(-)

Approvals:
  jenkins-bot: Verified
  Anomie: Looks good to me, approved



diff --git a/common/Hooks.php b/common/Hooks.php
index 83ee3ca..31a9fed 100644
--- a/common/Hooks.php
+++ b/common/Hooks.php
@@ -218,7 +218,16 @@
                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 );

-- 
To view, visit https://gerrit.wikimedia.org/r/348466
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I571aa4afed577e10be8b417cf1a3bf134a130739
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/Scribunto
Gerrit-Branch: master
Gerrit-Owner: Florianschmidtwelzow <[email protected]>
Gerrit-Reviewer: Anomie <[email protected]>
Gerrit-Reviewer: Florianschmidtwelzow <[email protected]>
Gerrit-Reviewer: Jackmcbarn <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to