From: jenkins-bot Date: Mon, 20 Mar 2017 09:32:47 +0000 (+0000) Subject: Merge "Replace deprecated Context::getStats() with MWServices::getStatsdDataFactory()" X-Git-Tag: 1.31.0-rc.0~3757 X-Git-Url: https://git.cyclocoop.org/%7B%24admin_url%7Dmembres/supprimer.php?a=commitdiff_plain;h=aa5eca02b3da03aae34269d823b26fe5609ed051;hp=e37ec98060b380d3e5a8f9efda65bdbfbea63c0c;p=lhc%2Fweb%2Fwiklou.git Merge "Replace deprecated Context::getStats() with MWServices::getStatsdDataFactory()" --- diff --git a/includes/api/ApiMain.php b/includes/api/ApiMain.php index 604fdf9e70..a1fac0cc3d 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 @@ class ApiMain extends ApiBase { $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 ea5278fc06..135c9b23eb 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 @@ abstract class ContextSource implements IContextSource { * @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 ab4a609d01..74266241c8 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 @@ class SiteStatsUpdate implements DeferrableUpdate, MergeableUpdate { } 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 148e50cf7c..b0ab24488f 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 @@ class DifferenceEngine extends ContextSource { $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 f7e85a8a40..e367812a8c 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 @@ abstract class File implements IDBAccessObject { $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 @@ abstract class File implements IDBAccessObject { public function generateAndSaveThumb( $tmpFile, $transformParams, $flags ) { global $wgIgnoreImageErrors; - $stats = RequestContext::getMain()->getStats(); + $stats = MediaWikiServices::getInstance()->getStatsdDataFactory(); $handler = $this->getHandler(); @@ -1227,7 +1228,7 @@ abstract class File implements IDBAccessObject { // 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 020a684728..9701dd9929 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 @@ abstract class JobQueue { 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 e7a906d4bf..cb97126ba3 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 @@ class Article implements Page { $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 52aa54acca..bb8655183c 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 @@ class ProfilerOutputStats extends ProfilerOutput { */ 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 717fb45804..e72eaf2988 100644 --- a/includes/resourceloader/ResourceLoader.php +++ b/includes/resourceloader/ResourceLoader.php @@ -185,7 +185,7 @@ class ResourceLoader implements LoggerAwareInterface { 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 5b862e4a21..5404e0fb9b 100644 --- a/includes/resourceloader/ResourceLoaderModule.php +++ b/includes/resourceloader/ResourceLoaderModule.php @@ -624,7 +624,7 @@ abstract class ResourceLoaderModule implements LoggerAwareInterface { */ 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 de201b914c..d97f8e8eac 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 @@ function wfStreamThumb( array $params ) { $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' ) ] );