Legoktm has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/376855 )

Change subject: Avoid using the deprecated ParserCache::singleton()
......................................................................

Avoid using the deprecated ParserCache::singleton()

Change-Id: I0da6d9cbfad26c89bf5dab564071ef97acaf44f9
---
M includes/api/ApiPurge.php
M includes/jobqueue/jobs/RefreshLinksJob.php
M includes/page/Article.php
M includes/page/WikiPage.php
M includes/poolcounter/PoolWorkArticleView.php
M maintenance/compareParserCache.php
6 files changed, 22 insertions(+), 11 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/55/376855/1

diff --git a/includes/api/ApiPurge.php b/includes/api/ApiPurge.php
index 83227a2..35f93e0 100644
--- a/includes/api/ApiPurge.php
+++ b/includes/api/ApiPurge.php
@@ -25,6 +25,7 @@
  * @file
  */
 use MediaWiki\Logger\LoggerFactory;
+use MediaWiki\MediaWikiServices;
 
 /**
  * API interface for page purging
@@ -98,7 +99,7 @@
                                                $r['linkupdate'] = true;
 
                                                if ( $enableParserCache ) {
-                                                       $pcache = 
ParserCache::singleton();
+                                                       $pcache = 
MediaWikiServices::getInstance()->getParserCache();
                                                        $pcache->save( 
$p_result, $page, $popts );
                                                }
                                        }
diff --git a/includes/jobqueue/jobs/RefreshLinksJob.php 
b/includes/jobqueue/jobs/RefreshLinksJob.php
index 9f3550f..ec2695c 100644
--- a/includes/jobqueue/jobs/RefreshLinksJob.php
+++ b/includes/jobqueue/jobs/RefreshLinksJob.php
@@ -207,7 +207,8 @@
                        if ( $page->getTouched() >= 
$this->params['rootJobTimestamp'] || $opportunistic ) {
                                // Cache is suspected to be up-to-date. As long 
as the cache rev ID matches
                                // and it reflects the job's triggering change, 
then it is usable.
-                               $parserOutput = 
ParserCache::singleton()->getDirty( $page, $parserOptions );
+                               $parserCache = 
MediaWikiServices::getInstance()->getParserCache();
+                               $parserOutput = $parserCache->getDirty( $page, 
$parserOptions );
                                if ( !$parserOutput
                                        || $parserOutput->getCacheRevisionId() 
!= $revision->getId()
                                        || $parserOutput->getCacheTime() < 
$skewedTimestamp
@@ -234,7 +235,8 @@
                                && $parserOutput->isCacheable()
                        ) {
                                $ctime = wfTimestamp( TS_MW, (int)$start ); // 
cache time
-                               ParserCache::singleton()->save(
+                               $parserCache = 
MediaWikiServices::getInstance()->getParserCache();
+                               $parserCache->save(
                                        $parserOutput, $page, $parserOptions, 
$ctime, $revision->getId()
                                );
                        }
diff --git a/includes/page/Article.php b/includes/page/Article.php
index f52cd8d..5b03a22 100644
--- a/includes/page/Article.php
+++ b/includes/page/Article.php
@@ -466,7 +466,7 @@
                # Allow frames by default
                $outputPage->allowClickjacking();
 
-               $parserCache = ParserCache::singleton();
+               $parserCache = 
MediaWikiServices::getInstance()->getParserCache();
 
                $parserOptions = $this->getParserOptions();
                # Render printable version, use printable version cache
diff --git a/includes/page/WikiPage.php b/includes/page/WikiPage.php
index bf8a597..bb414b1 100644
--- a/includes/page/WikiPage.php
+++ b/includes/page/WikiPage.php
@@ -1070,7 +1070,7 @@
                }
 
                if ( $useParserCache ) {
-                       $parserOutput = ParserCache::singleton()->get( $this, 
$parserOptions );
+                       $parserOutput = 
MediaWikiServices::getInstance()->getParserCache()->get( $this, $parserOptions 
);
                        if ( $parserOutput !== false ) {
                                return $parserOutput;
                        }
@@ -2162,7 +2162,7 @@
 
                // Save it to the parser cache.
                // Make sure the cache time matches page_touched to avoid 
double parsing.
-               ParserCache::singleton()->save(
+               MediaWikiServices::getInstance()->getParserCache()->save(
                        $editInfo->output, $this, $editInfo->popts,
                        $revision->getTimestamp(), $editInfo->revid
                );
diff --git a/includes/poolcounter/PoolWorkArticleView.php 
b/includes/poolcounter/PoolWorkArticleView.php
index 1f1add7..17b62d7 100644
--- a/includes/poolcounter/PoolWorkArticleView.php
+++ b/includes/poolcounter/PoolWorkArticleView.php
@@ -17,6 +17,7 @@
  *
  * @file
  */
+use MediaWiki\MediaWikiServices;
 
 class PoolWorkArticleView extends PoolCounterWork {
        /** @var WikiPage */
@@ -27,6 +28,9 @@
 
        /** @var int */
        private $revid;
+
+       /** @var ParserCache */
+       private $parserCache;
 
        /** @var ParserOptions */
        private $parserOptions;
@@ -66,7 +70,8 @@
                $this->cacheable = $useParserCache;
                $this->parserOptions = $parserOptions;
                $this->content = $content;
-               $this->cacheKey = ParserCache::singleton()->getKey( $page, 
$parserOptions );
+               $this->parserCache = 
MediaWikiServices::getInstance()->getParserCache();
+               $this->cacheKey = $this->parserCache->getKey( $page, 
$parserOptions );
                $keyPrefix = $this->cacheKey ?: wfMemcKey( 'articleview', 
'missingcachekey' );
                parent::__construct( 'ArticleView', $keyPrefix . ':revid:' . 
$revid );
        }
@@ -153,7 +158,7 @@
                }
 
                if ( $this->cacheable && $this->parserOutput->isCacheable() && 
$isCurrent ) {
-                       ParserCache::singleton()->save(
+                       $this->parserCache->save(
                                $this->parserOutput, $this->page, 
$this->parserOptions, $cacheTime, $this->revid );
                }
 
@@ -175,7 +180,7 @@
         * @return bool
         */
        public function getCachedWork() {
-               $this->parserOutput = ParserCache::singleton()->get( 
$this->page, $this->parserOptions );
+               $this->parserOutput = $this->parserCache->get( $this->page, 
$this->parserOptions );
 
                if ( $this->parserOutput === false ) {
                        wfDebug( __METHOD__ . ": parser cache miss\n" );
@@ -190,7 +195,7 @@
         * @return bool
         */
        public function fallback() {
-               $this->parserOutput = ParserCache::singleton()->getDirty( 
$this->page, $this->parserOptions );
+               $this->parserOutput = $this->parserCache->getDirty( 
$this->page, $this->parserOptions );
 
                if ( $this->parserOutput === false ) {
                        wfDebugLog( 'dirty', 'dirty missing' );
diff --git a/maintenance/compareParserCache.php 
b/maintenance/compareParserCache.php
index 8bd060f..504c7d7 100644
--- a/maintenance/compareParserCache.php
+++ b/maintenance/compareParserCache.php
@@ -21,6 +21,8 @@
 
 require_once __DIR__ . '/Maintenance.php';
 
+use MediaWiki\MediaWikiServices;
+
 /**
  * @ingroup Maintenance
  */
@@ -41,6 +43,7 @@
                $scanned = 0;
                $withcache = 0;
                $withdiff = 0;
+               $parserCache = 
MediaWikiServices::getInstance()->getParserCache();
                while ( $pages-- > 0 ) {
                        $row = $dbr->selectRow( 'page', '*',
                                [
@@ -66,7 +69,7 @@
 
                        $parserOptions = $page->makeParserOptions( 'canonical' 
);
 
-                       $parserOutputOld = ParserCache::singleton()->get( 
$page, $parserOptions );
+                       $parserOutputOld = $parserCache->get( $page, 
$parserOptions );
 
                        if ( $parserOutputOld ) {
                                $t1 = microtime( true );

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I0da6d9cbfad26c89bf5dab564071ef97acaf44f9
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Legoktm <lego...@member.fsf.org>

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

Reply via email to