From: Aaron Schulz Date: Wed, 7 Sep 2016 19:00:52 +0000 (-0700) Subject: Fix ApiStashEdit IDEA warnings X-Git-Tag: 1.31.0-rc.0~5720^2 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/exercices/?a=commitdiff_plain;h=ae648472b09e1216acf85b2550d804e7fd79c463;p=lhc%2Fweb%2Fwiklou.git Fix ApiStashEdit IDEA warnings Change-Id: Icc1d0225908e432df10c36d69c6ed282f8761198 --- diff --git a/includes/api/ApiStashEdit.php b/includes/api/ApiStashEdit.php index bbfc17a525..5a2492de3a 100644 --- a/includes/api/ApiStashEdit.php +++ b/includes/api/ApiStashEdit.php @@ -20,6 +20,7 @@ */ use MediaWiki\Logger\LoggerFactory; +use MediaWiki\MediaWikiServices; /** * Prepare an edit in shared cache so that it can be reused on edit @@ -62,6 +63,8 @@ class ApiStashEdit extends ApiBase { $this->dieUsage( 'Unsupported content model/format', 'badmodelformat' ); } + $text = null; + $textHash = null; if ( strlen( $params['stashedtexthash'] ) ) { // Load from cache since the client indicates the text is the same as last stash $textHash = $params['stashedtexthash']; @@ -138,7 +141,8 @@ class ApiStashEdit extends ApiBase { $cache->set( $textKey, $text, self::MAX_CACHE_TTL ); } - $this->getStats()->increment( "editstash.cache_stores.$status" ); + $stats = MediaWikiServices::getInstance()->getStatsdDataFactory(); + $stats->increment( "editstash.cache_stores.$status" ); $this->getResult()->addValue( null, @@ -171,6 +175,7 @@ class ApiStashEdit extends ApiBase { // De-duplicate requests on the same key return self::ERROR_BUSY; } + /** @noinspection PhpUnusedLocalVariableInspection */ $unlocker = new ScopedCallback( function () use ( $dbw, $key ) { $dbw->unlock( $key, __METHOD__ ); } ); @@ -246,7 +251,7 @@ class ApiStashEdit extends ApiBase { $cache = ObjectCache::getLocalClusterInstance(); $logger = LoggerFactory::getInstance( 'StashEdit' ); - $stats = RequestContext::getMain()->getStats(); + $stats = MediaWikiServices::getInstance()->getStatsdDataFactory(); $key = self::getStashKey( $title, self::getContentHash( $content ), $user ); $editInfo = $cache->get( $key ); @@ -256,7 +261,7 @@ class ApiStashEdit extends ApiBase { // so as to use its results and make use of the time spent parsing. // Skip this logic if there no master connection in case this method // is called on an HTTP GET request for some reason. - $lb = wfGetLB(); + $lb = MediaWikiServices::getInstance()->getDBLoadBalancer(); $dbw = $lb->getAnyOpenConnection( $lb->getWriterIndex() ); if ( $dbw && $dbw->lock( $key, __METHOD__, 30 ) ) { $editInfo = $cache->get( $key );