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

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


Remove usage of RequestContext::getStats()

Bug: T156810
Change-Id: I985b22f8d0235e132c0c34a51da4bea992432209
---
M WikimediaEventsHooks.php
1 file changed, 8 insertions(+), 9 deletions(-)

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



diff --git a/WikimediaEventsHooks.php b/WikimediaEventsHooks.php
index 821077a..547657c 100644
--- a/WikimediaEventsHooks.php
+++ b/WikimediaEventsHooks.php
@@ -70,13 +70,13 @@
                        return;
                }
 
+               $stats = 
MediaWikiServices::getInstance()->getStatsdDataFactory();
                if ( PHP_SAPI !== 'cli' ) {
-                       DeferredUpdates::addCallableUpdate( function () {
-                               $context = RequestContext::getMain();
-                               $timing = $context->getTiming();
+                       DeferredUpdates::addCallableUpdate( function () use ( 
$stats ) {
+                               $timing = 
RequestContext::getMain()->getTiming();
                                $measure = $timing->measure( 
'editResponseTime', 'requestStart', 'requestShutdown' );
                                if ( $measure !== false ) {
-                                       $context->getStats()->timing( 
'timing.editResponseTime', $measure['duration'] * 1000 );
+                                       $stats->timing( 
'timing.editResponseTime', $measure['duration'] * 1000 );
                                }
                        } );
                }
@@ -113,7 +113,6 @@
                // are important indicators of community health.
                if ( $editCount === 0 || preg_match( '/^9+$/' , "$editCount" ) 
) {
                        $milestone = $editCount + 1;
-                       $stats = RequestContext::getMain()->getStats();
                        $stats->increment( "editor.milestones.{$milestone}" );
                        $stats->timing( 
"editor.milestones.timing.{$milestone}", $age );
                }
@@ -147,7 +146,6 @@
         * @param array $flags
         */
        public static function onRevisionInsertComplete( &$revision, $data, 
$flags ) {
-               $context = RequestContext::getMain();
                $user = User::newFromId( $revision->getUser( Revision::RAW ) );
 
                // Anonymous users and bots don't count (sorry!)
@@ -163,7 +161,7 @@
                // Check if this is the user's fifth mainspace edit this month.
                // If it is, then this editor has just made the cut as an active
                // editor for this wiki for this month.
-               DeferredUpdates::addCallableUpdate( function () use ( $context, 
$user ) {
+               DeferredUpdates::addCallableUpdate( function () use ( $user ) {
                        $db = wfGetDB( DB_MASTER );
 
                        $since = date( 'Ym' ) . '00000000';
@@ -182,7 +180,8 @@
 
                        if ( $numMainspaceEditsThisMonth === 5 ) {
                                $month = date( 'm-Y' );
-                               $context->getStats()->increment( 
'editor.activation.' . $month );
+                               MediaWikiServices::getInstance()
+                                       ->getStatsdDataFactory()->increment( 
'editor.activation.' . $month );
                                EventLogging::logEvent( 'EditorActivation', 
14208837, array(
                                        'userId' => $user->getId(),
                                        'month'  => $month,
@@ -519,7 +518,7 @@
 
                        $measure = $timing->measure( 'viewResponseTime', 
'requestStart', 'requestShutdown' );
                        if ( $measure !== false ) {
-                               $context->getStats()->timing(
+                               
MediaWikiServices::getInstance()->getStatsdDataFactory()->timing(
                                        "timing.viewResponseTime.{$platform}", 
$measure['duration'] * 1000 );
                        }
                } );

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I985b22f8d0235e132c0c34a51da4bea992432209
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/WikimediaEvents
Gerrit-Branch: master
Gerrit-Owner: Florianschmidtwelzow <[email protected]>
Gerrit-Reviewer: Florianschmidtwelzow <[email protected]>
Gerrit-Reviewer: Krinkle <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to