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

Change subject: Replace deprecated Context::getStats() with 
MWServices::getStatsdDataFactory()
......................................................................


Replace deprecated Context::getStats() with MWServices::getStatsdDataFactory()

Change-Id: I1756f69ca2ebd301a5049bf758d1a87c37771fe6
---
M includes/api/ApiMain.php
M includes/context/ContextSource.php
M includes/deferred/SiteStatsUpdate.php
M includes/diff/DifferenceEngine.php
M includes/filerepo/file/File.php
M includes/jobqueue/JobQueue.php
M includes/page/Article.php
M includes/profiler/output/ProfilerOutputStats.php
M includes/resourceloader/ResourceLoader.php
M includes/resourceloader/ResourceLoaderModule.php
M thumb.php
11 files changed, 24 insertions(+), 13 deletions(-)

Approvals:
  Krinkle: Looks good to me, but someone else must approve
  Addshore: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/api/ApiMain.php b/includes/api/ApiMain.php
index 604fdf9..a1fac0c 100644
--- a/includes/api/ApiMain.php
+++ b/includes/api/ApiMain.php
@@ -26,6 +26,7 @@
  */
 
 use MediaWiki\Logger\LoggerFactory;
+use MediaWiki\MediaWikiServices;
 use Wikimedia\Timestamp\TimestampException;
 
 /**
@@ -544,7 +545,7 @@
                        $runTime = microtime( true ) - $t;
                        $this->logRequest( $runTime );
                        if ( $this->mModule->isWriteMode() && 
$this->getRequest()->wasPosted() ) {
-                               $this->getStats()->timing(
+                               
MediaWikiServices::getInstance()->getStatsdDataFactory()->timing(
                                        'api.' . 
$this->mModule->getModuleName() . '.executeTiming', 1000 * $runTime
                                );
                        }
diff --git a/includes/context/ContextSource.php 
b/includes/context/ContextSource.php
index ea5278f..135c9b2 100644
--- a/includes/context/ContextSource.php
+++ b/includes/context/ContextSource.php
@@ -19,6 +19,7 @@
  * @file
  */
 use Liuggio\StatsdClient\Factory\StatsdDataFactory;
+use MediaWiki\MediaWikiServices;
 
 /**
  * The simplest way of implementing IContextSource is to hold a RequestContext 
as a
@@ -172,7 +173,7 @@
         * @return StatsdDataFactory
         */
        public function getStats() {
-               return $this->getContext()->getStats();
+               return MediaWikiServices::getInstance()->getStatsdDataFactory();
        }
 
        /**
diff --git a/includes/deferred/SiteStatsUpdate.php 
b/includes/deferred/SiteStatsUpdate.php
index ab4a609..7426624 100644
--- a/includes/deferred/SiteStatsUpdate.php
+++ b/includes/deferred/SiteStatsUpdate.php
@@ -17,6 +17,7 @@
  *
  * @file
  */
+use MediaWiki\MediaWikiServices;
 use Wikimedia\Assert\Assert;
 
 /**
@@ -169,7 +170,7 @@
        }
 
        protected function doUpdateContextStats() {
-               $stats = RequestContext::getMain()->getStats();
+               $stats = 
MediaWikiServices::getInstance()->getStatsdDataFactory();
                foreach ( [ 'edits', 'articles', 'pages', 'users', 'images' ] 
as $type ) {
                        $delta = $this->$type;
                        if ( $delta !== 0 ) {
diff --git a/includes/diff/DifferenceEngine.php 
b/includes/diff/DifferenceEngine.php
index 148e50c..b0ab244 100644
--- a/includes/diff/DifferenceEngine.php
+++ b/includes/diff/DifferenceEngine.php
@@ -20,6 +20,7 @@
  * @file
  * @ingroup DifferenceEngine
  */
+use MediaWiki\MediaWikiServices;
 
 /** @deprecated use class constant instead */
 define( 'MW_DIFF_VERSION', '1.11a' );
@@ -852,7 +853,7 @@
                        $result = $this->textDiff( $otext, $ntext );
 
                        $time = intval( ( microtime( true ) - $time ) * 1000 );
-                       $this->getStats()->timing( 'diff_time', $time );
+                       
MediaWikiServices::getInstance()->getStatsdDataFactory()->timing( 'diff_time', 
$time );
                        // Log requests slower than 99th percentile
                        if ( $time > 100 && $this->mOldPage && $this->mNewPage 
) {
                                wfDebugLog( 'diff',
diff --git a/includes/filerepo/file/File.php b/includes/filerepo/file/File.php
index f7e85a8..e367812 100644
--- a/includes/filerepo/file/File.php
+++ b/includes/filerepo/file/File.php
@@ -5,6 +5,7 @@
  *
  * Represents files in a repository.
  */
+use MediaWiki\MediaWikiServices;
 
 /**
  * Base code for files.
@@ -436,7 +437,7 @@
                        $this->fsFile = $this->repo->getLocalReference( 
$this->getPath() );
 
                        $statTiming = microtime( true ) - $starttime;
-                       RequestContext::getMain()->getStats()->timing(
+                       
MediaWikiServices::getInstance()->getStatsdDataFactory()->timing(
                                'media.thumbnail.generate.fetchoriginal', 1000 
* $statTiming );
 
                        if ( !$this->fsFile ) {
@@ -1117,7 +1118,7 @@
        public function generateAndSaveThumb( $tmpFile, $transformParams, 
$flags ) {
                global $wgIgnoreImageErrors;
 
-               $stats = RequestContext::getMain()->getStats();
+               $stats = 
MediaWikiServices::getInstance()->getStatsdDataFactory();
 
                $handler = $this->getHandler();
 
@@ -1227,7 +1228,7 @@
                // this object exists
                $tmpFile->bind( $this );
 
-               RequestContext::getMain()->getStats()->timing(
+               
MediaWikiServices::getInstance()->getStatsdDataFactory()->timing(
                        'media.thumbnail.generate.bucket', 1000 * $buckettime );
 
                return true;
diff --git a/includes/jobqueue/JobQueue.php b/includes/jobqueue/JobQueue.php
index 020a684..9701dd9 100644
--- a/includes/jobqueue/JobQueue.php
+++ b/includes/jobqueue/JobQueue.php
@@ -21,6 +21,7 @@
  * @defgroup JobQueue JobQueue
  * @author Aaron Schulz
  */
+use MediaWiki\MediaWikiServices;
 
 /**
  * Class to handle enqueueing and running of background jobs
@@ -709,7 +710,7 @@
        public static function incrStats( $key, $type, $delta = 1 ) {
                static $stats;
                if ( !$stats ) {
-                       $stats = RequestContext::getMain()->getStats();
+                       $stats = 
MediaWikiServices::getInstance()->getStatsdDataFactory();
                }
                $stats->updateCount( "jobqueue.{$key}.all", $delta );
                $stats->updateCount( "jobqueue.{$key}.{$type}", $delta );
diff --git a/includes/page/Article.php b/includes/page/Article.php
index e7a906d..cb97126 100644
--- a/includes/page/Article.php
+++ b/includes/page/Article.php
@@ -19,6 +19,7 @@
  *
  * @file
  */
+use MediaWiki\MediaWikiServices;
 
 /**
  * Class for viewing MediaWiki article and history.
@@ -494,7 +495,7 @@
                $useParserCache = $this->mPage->shouldCheckParserCache( 
$parserOptions, $oldid );
                wfDebug( 'Article::view using parser cache: ' . ( 
$useParserCache ? 'yes' : 'no' ) . "\n" );
                if ( $user->getStubThreshold() ) {
-                       $this->getContext()->getStats()->increment( 
'pcache_miss_stub' );
+                       
MediaWikiServices::getInstance()->getStatsdDataFactory()->increment( 
'pcache_miss_stub' );
                }
 
                $this->showRedirectedFromHeader();
diff --git a/includes/profiler/output/ProfilerOutputStats.php 
b/includes/profiler/output/ProfilerOutputStats.php
index 52aa54a..bb86551 100644
--- a/includes/profiler/output/ProfilerOutputStats.php
+++ b/includes/profiler/output/ProfilerOutputStats.php
@@ -21,6 +21,7 @@
  * @file
  * @ingroup Profiler
  */
+use MediaWiki\MediaWikiServices;
 
 /**
  * ProfilerOutput class that flushes profiling data to the profiling
@@ -38,7 +39,7 @@
         */
        public function log( array $stats ) {
                $prefix = isset( $this->params['prefix'] ) ? 
$this->params['prefix'] : '';
-               $contextStats = $this->collector->getContext()->getStats();
+               $contextStats = 
MediaWikiServices::getInstance()->getStatsdDataFactory();
 
                foreach ( $stats as $stat ) {
                        $key = "{$prefix}.{$stat['name']}";
diff --git a/includes/resourceloader/ResourceLoader.php 
b/includes/resourceloader/ResourceLoader.php
index 717fb45..e72eaf2 100644
--- a/includes/resourceloader/ResourceLoader.php
+++ b/includes/resourceloader/ResourceLoader.php
@@ -185,7 +185,7 @@
                        return self::applyFilter( $filter, $data );
                }
 
-               $stats = RequestContext::getMain()->getStats();
+               $stats = 
MediaWikiServices::getInstance()->getStatsdDataFactory();
                $cache = ObjectCache::getLocalServerInstance( CACHE_ANYTHING );
 
                $key = $cache->makeGlobalKey(
diff --git a/includes/resourceloader/ResourceLoaderModule.php 
b/includes/resourceloader/ResourceLoaderModule.php
index a2b4b1d..b122fe2 100644
--- a/includes/resourceloader/ResourceLoaderModule.php
+++ b/includes/resourceloader/ResourceLoaderModule.php
@@ -624,7 +624,7 @@
         */
        final protected function buildContent( ResourceLoaderContext $context ) 
{
                $rl = $context->getResourceLoader();
-               $stats = RequestContext::getMain()->getStats();
+               $stats = 
MediaWikiServices::getInstance()->getStatsdDataFactory();
                $statStart = microtime( true );
 
                // Only include properties that are relevant to this context 
(e.g. only=scripts)
diff --git a/thumb.php b/thumb.php
index de201b9..d97f8e8 100644
--- a/thumb.php
+++ b/thumb.php
@@ -22,6 +22,7 @@
  */
 
 use MediaWiki\Logger\LoggerFactory;
+use MediaWiki\MediaWikiServices;
 
 define( 'MW_NO_OUTPUT_COMPRESSION', 1 );
 require __DIR__ . '/includes/WebStart.php';
@@ -317,7 +318,9 @@
                $streamtime = microtime( true ) - $starttime;
 
                if ( $status->isOK() ) {
-                       RequestContext::getMain()->getStats()->timing( 
'media.thumbnail.stream', $streamtime );
+                       
MediaWikiServices::getInstance()->getStatsdDataFactory()->timing(
+                               'media.thumbnail.stream', $streamtime
+                       );
                } else {
                        wfThumbError( 500, 'Could not stream the file', null, [ 
'file' => $thumbName,
                                'path' => $thumbPath, 'error' => 
$status->getWikiText( false, false, 'en' ) ] );

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I1756f69ca2ebd301a5049bf758d1a87c37771fe6
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: WMDE-Fisch <christoph.jau...@wikimedia.de>
Gerrit-Reviewer: Aaron Schulz <asch...@wikimedia.org>
Gerrit-Reviewer: Addshore <addshorew...@gmail.com>
Gerrit-Reviewer: Anomie <bjor...@wikimedia.org>
Gerrit-Reviewer: Krinkle <krinklem...@gmail.com>
Gerrit-Reviewer: Legoktm <lego...@member.fsf.org>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to