Avoid deprecated LinkCache::singleton()
Change-Id: Ie0e5c4ef0fe6ec896378bb2433af0898655dd907
This commit is contained in:
parent
dc96f656af
commit
c4e5a9dd97
15 changed files with 45 additions and 32 deletions
|
|
@ -1368,7 +1368,8 @@ class OutputPage extends ContextSource {
|
|||
);
|
||||
|
||||
# Add the results to the link cache
|
||||
$lb->addResultToCache( LinkCache::singleton(), $res );
|
||||
$linkCache = MediaWikiServices::getInstance()->getLinkCache();
|
||||
$lb->addResultToCache( $linkCache, $res );
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -979,7 +979,7 @@ class Title implements LinkTarget {
|
|||
&& ( !$this->mContentModel || $flags === self::GAID_FOR_UPDATE )
|
||||
&& $this->getArticleID( $flags )
|
||||
) {
|
||||
$linkCache = LinkCache::singleton();
|
||||
$linkCache = MediaWikiServices::getInstance()->getLinkCache();
|
||||
$linkCache->addLinkObj( $this ); # in case we already had an article ID
|
||||
$this->mContentModel = $linkCache->getGoodLinkFieldObj( $this, 'model' );
|
||||
}
|
||||
|
|
@ -3430,7 +3430,7 @@ class Title implements LinkTarget {
|
|||
$this->mArticleID = 0;
|
||||
return $this->mArticleID;
|
||||
}
|
||||
$linkCache = LinkCache::singleton();
|
||||
$linkCache = MediaWikiServices::getInstance()->getLinkCache();
|
||||
if ( $flags & self::GAID_FOR_UPDATE ) {
|
||||
$oldUpdate = $linkCache->forUpdate( true );
|
||||
$linkCache->clearLink( $this );
|
||||
|
|
@ -3460,7 +3460,7 @@ class Title implements LinkTarget {
|
|||
return $this->mRedirect;
|
||||
}
|
||||
|
||||
$linkCache = LinkCache::singleton();
|
||||
$linkCache = MediaWikiServices::getInstance()->getLinkCache();
|
||||
$linkCache->addLinkObj( $this ); # in case we already had an article ID
|
||||
$cached = $linkCache->getGoodLinkFieldObj( $this, 'redirect' );
|
||||
if ( $cached === null ) {
|
||||
|
|
@ -3494,7 +3494,7 @@ class Title implements LinkTarget {
|
|||
$this->mLength = 0;
|
||||
return $this->mLength;
|
||||
}
|
||||
$linkCache = LinkCache::singleton();
|
||||
$linkCache = MediaWikiServices::getInstance()->getLinkCache();
|
||||
$linkCache->addLinkObj( $this ); # in case we already had an article ID
|
||||
$cached = $linkCache->getGoodLinkFieldObj( $this, 'length' );
|
||||
if ( $cached === null ) {
|
||||
|
|
@ -3522,7 +3522,7 @@ class Title implements LinkTarget {
|
|||
$this->mLatestID = 0;
|
||||
return $this->mLatestID;
|
||||
}
|
||||
$linkCache = LinkCache::singleton();
|
||||
$linkCache = MediaWikiServices::getInstance()->getLinkCache();
|
||||
$linkCache->addLinkObj( $this ); # in case we already had an article ID
|
||||
$cached = $linkCache->getGoodLinkFieldObj( $this, 'revision' );
|
||||
if ( $cached === null ) {
|
||||
|
|
@ -3547,7 +3547,7 @@ class Title implements LinkTarget {
|
|||
* @param int $newid The new Article ID
|
||||
*/
|
||||
public function resetArticleID( $newid ) {
|
||||
$linkCache = LinkCache::singleton();
|
||||
$linkCache = MediaWikiServices::getInstance()->getLinkCache();
|
||||
$linkCache->clearLink( $this );
|
||||
|
||||
if ( $newid === false ) {
|
||||
|
|
@ -3569,7 +3569,7 @@ class Title implements LinkTarget {
|
|||
}
|
||||
|
||||
public static function clearCaches() {
|
||||
$linkCache = LinkCache::singleton();
|
||||
$linkCache = MediaWikiServices::getInstance()->getLinkCache();
|
||||
$linkCache->clear();
|
||||
|
||||
$titleCache = self::getTitleCache();
|
||||
|
|
@ -3673,7 +3673,7 @@ class Title implements LinkTarget {
|
|||
|
||||
$retVal = [];
|
||||
if ( $res->numRows() ) {
|
||||
$linkCache = LinkCache::singleton();
|
||||
$linkCache = MediaWikiServices::getInstance()->getLinkCache();
|
||||
foreach ( $res as $row ) {
|
||||
$titleObj = self::makeTitle( $row->page_namespace, $row->page_title );
|
||||
if ( $titleObj ) {
|
||||
|
|
@ -3741,7 +3741,7 @@ class Title implements LinkTarget {
|
|||
);
|
||||
|
||||
$retVal = [];
|
||||
$linkCache = LinkCache::singleton();
|
||||
$linkCache = MediaWikiServices::getInstance()->getLinkCache();
|
||||
foreach ( $res as $row ) {
|
||||
if ( $row->page_id ) {
|
||||
$titleObj = self::newFromRow( $row );
|
||||
|
|
@ -4940,7 +4940,7 @@ class Title implements LinkTarget {
|
|||
// check, if the page language could be saved in the database, and if so and
|
||||
// the value is not requested already, lookup the page language using LinkCache
|
||||
if ( $wgPageLanguageUseDB && $this->mDbPageLanguage === false ) {
|
||||
$linkCache = LinkCache::singleton();
|
||||
$linkCache = MediaWikiServices::getInstance()->getLinkCache();
|
||||
$linkCache->addLinkObj( $this );
|
||||
$this->mDbPageLanguage = $linkCache->getGoodLinkFieldObj( $this, 'lang' );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -771,7 +771,8 @@ class ApiPageSet extends ApiBase {
|
|||
// Store Title object in various data structures
|
||||
$title = Title::newFromRow( $row );
|
||||
|
||||
LinkCache::singleton()->addGoodLinkObjFromRow( $title, $row );
|
||||
$linkCache = MediaWikiServices::getInstance()->getLinkCache();
|
||||
$linkCache->addGoodLinkObjFromRow( $title, $row );
|
||||
|
||||
$pageId = intval( $row->page_id );
|
||||
$this->mAllPages[$row->page_namespace][$row->page_title] = $pageId;
|
||||
|
|
@ -904,7 +905,7 @@ class ApiPageSet extends ApiBase {
|
|||
// Any items left in the $remaining list are added as missing
|
||||
if ( $processTitles ) {
|
||||
// The remaining titles in $remaining are non-existent pages
|
||||
$linkCache = LinkCache::singleton();
|
||||
$linkCache = MediaWikiServices::getInstance()->getLinkCache();
|
||||
foreach ( $remaining as $ns => $dbkeys ) {
|
||||
foreach ( array_keys( $dbkeys ) as $dbkey ) {
|
||||
$title = Title::makeTitle( $ns, $dbkey );
|
||||
|
|
|
|||
|
|
@ -697,7 +697,7 @@ class ApiParse extends ApiBase {
|
|||
$hiddencats[$row->page_title] = isset( $row->pp_propname );
|
||||
}
|
||||
|
||||
$linkCache = LinkCache::singleton();
|
||||
$linkCache = MediaWikiServices::getInstance()->getLinkCache();
|
||||
|
||||
foreach ( $links as $link => $sortkey ) {
|
||||
$entry = [];
|
||||
|
|
|
|||
|
|
@ -468,7 +468,7 @@ class WikiPage implements Page, IDBAccessObject {
|
|||
* the master DB using SELECT FOR UPDATE
|
||||
*/
|
||||
public function loadFromRow( $data, $from ) {
|
||||
$lc = LinkCache::singleton();
|
||||
$lc = MediaWikiServices::getInstance()->getLinkCache();
|
||||
$lc->clearLink( $this->mTitle );
|
||||
|
||||
if ( $data ) {
|
||||
|
|
@ -1297,7 +1297,8 @@ class WikiPage implements Page, IDBAccessObject {
|
|||
$this->mLatest = $revision->getId();
|
||||
$this->mIsRedirect = (bool)$rt;
|
||||
// Update the LinkCache.
|
||||
LinkCache::singleton()->addGoodLinkObj(
|
||||
$linkCache = MediaWikiServices::getInstance()->getLinkCache();
|
||||
$linkCache->addGoodLinkObj(
|
||||
$this->getId(),
|
||||
$this->mTitle,
|
||||
$len,
|
||||
|
|
|
|||
|
|
@ -1162,7 +1162,7 @@ class CoreParserFunctions {
|
|||
}
|
||||
|
||||
// Check the link cache, maybe something already looked it up.
|
||||
$linkCache = LinkCache::singleton();
|
||||
$linkCache = MediaWikiServices::getInstance()->getLinkCache();
|
||||
$pdbk = $t->getPrefixedDBkey();
|
||||
$id = $linkCache->getGoodLinkID( $pdbk );
|
||||
if ( $id != 0 ) {
|
||||
|
|
|
|||
|
|
@ -21,6 +21,8 @@
|
|||
* @ingroup Parser
|
||||
*/
|
||||
|
||||
use MediaWiki\MediaWikiServices;
|
||||
|
||||
/**
|
||||
* @ingroup Parser
|
||||
*/
|
||||
|
|
@ -283,7 +285,7 @@ class LinkHolderArray {
|
|||
global $wgContLang;
|
||||
|
||||
$colours = [];
|
||||
$linkCache = LinkCache::singleton();
|
||||
$linkCache = MediaWikiServices::getInstance()->getLinkCache();
|
||||
$output = $this->parent->getOutput();
|
||||
$linkRenderer = $this->parent->getLinkRenderer();
|
||||
|
||||
|
|
@ -451,7 +453,7 @@ class LinkHolderArray {
|
|||
$linkBatch = new LinkBatch();
|
||||
$variantMap = []; // maps $pdbkey_Variant => $keys (of link holders)
|
||||
$output = $this->parent->getOutput();
|
||||
$linkCache = LinkCache::singleton();
|
||||
$linkCache = MediaWikiServices::getInstance()->getLinkCache();
|
||||
$titlesToBeConverted = '';
|
||||
$titlesAttrs = [];
|
||||
|
||||
|
|
|
|||
|
|
@ -3631,7 +3631,7 @@ class Parser {
|
|||
$rev_id = $rev ? $rev->getId() : 0;
|
||||
# If there is no current revision, there is no page
|
||||
if ( $id === false && !$rev ) {
|
||||
$linkCache = LinkCache::singleton();
|
||||
$linkCache = MediaWikiServices::getInstance()->getLinkCache();
|
||||
$linkCache->addBadLinkObj( $title );
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,6 +20,8 @@
|
|||
* @file
|
||||
* @ingroup Parser
|
||||
*/
|
||||
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use Wikimedia\ScopedCallback;
|
||||
|
||||
/**
|
||||
|
|
@ -1386,11 +1388,12 @@ class ParserOptions {
|
|||
};
|
||||
end( $wgHooks['TitleExists'] );
|
||||
$key = key( $wgHooks['TitleExists'] );
|
||||
LinkCache::singleton()->clearBadLink( $title->getPrefixedDBkey() );
|
||||
return new ScopedCallback( function () use ( $title, $key ) {
|
||||
$linkCache = MediaWikiServices::getInstance()->getLinkCache();
|
||||
$linkCache->clearBadLink( $title->getPrefixedDBkey() );
|
||||
return new ScopedCallback( function () use ( $title, $key, $linkCache ) {
|
||||
global $wgHooks;
|
||||
unset( $wgHooks['TitleExists'][$key] );
|
||||
LinkCache::singleton()->clearLink( $title );
|
||||
$linkCache->clearLink( $title );
|
||||
} );
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@
|
|||
* @ingroup Maintenance
|
||||
*/
|
||||
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use Wikimedia\Rdbms\IDatabase;
|
||||
|
||||
require_once __DIR__ . '/Maintenance.php';
|
||||
|
|
@ -258,7 +259,7 @@ class RefreshLinks extends Maintenance {
|
|||
public static function fixLinksFromArticle( $id, $ns = false ) {
|
||||
$page = WikiPage::newFromID( $id );
|
||||
|
||||
LinkCache::singleton()->clear();
|
||||
MediaWikiServices::getInstance()->getLinkCache()->clear();
|
||||
|
||||
if ( $page === null ) {
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -1281,7 +1281,7 @@ class ParserTestRunner {
|
|||
|
||||
// Wipe some DB query result caches on setup and teardown
|
||||
$reset = function () {
|
||||
LinkCache::singleton()->clear();
|
||||
MediaWikiServices::getInstance()->getLinkCache()->clear();
|
||||
|
||||
// Clear the message cache
|
||||
MessageCache::singleton()->clear();
|
||||
|
|
|
|||
|
|
@ -1486,7 +1486,7 @@ abstract class MediaWikiTestCase extends PHPUnit\Framework\TestCase {
|
|||
if ( $tbl === 'page' ) {
|
||||
// Forget about the pages since they don't
|
||||
// exist in the DB.
|
||||
LinkCache::singleton()->clear();
|
||||
MediaWikiServices::getInstance()->getLinkCache()->clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1601,7 +1601,7 @@ abstract class MediaWikiTestCase extends PHPUnit\Framework\TestCase {
|
|||
if ( $tbl === 'page' ) {
|
||||
// Forget about the pages since they don't
|
||||
// exist in the DB.
|
||||
LinkCache::singleton()->clear();
|
||||
MediaWikiServices::getInstance()->getLinkCache()->clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
use MediaWiki\MediaWikiServices;
|
||||
|
||||
/**
|
||||
* @group ContentHandler
|
||||
* @group Database
|
||||
|
|
@ -353,7 +355,7 @@ class TitleMethodsTest extends MediaWikiLangTestCase {
|
|||
* @covers Title::clearCaches
|
||||
*/
|
||||
public function testClearCaches() {
|
||||
$linkCache = LinkCache::singleton();
|
||||
$linkCache = MediaWikiServices::getInstance()->getLinkCache();
|
||||
|
||||
$title1 = Title::newFromText( 'Foo' );
|
||||
$linkCache->addGoodLinkObj( 23, $title1 );
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
use MediaWiki\MediaWikiServices;
|
||||
|
||||
/**
|
||||
* @group Database
|
||||
* @group Title
|
||||
|
|
@ -674,7 +676,7 @@ class TitleTest extends MediaWikiTestCase {
|
|||
*/
|
||||
public function testExists() {
|
||||
$title = Title::makeTitle( NS_PROJECT, 'New page' );
|
||||
$linkCache = LinkCache::singleton();
|
||||
$linkCache = MediaWikiServices::getInstance()->getLinkCache();
|
||||
|
||||
$article = new Article( $title );
|
||||
$page = $article->getPage();
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ class ContentHandlerTest extends MediaWikiTestCase {
|
|||
*/
|
||||
public function testGetForTitle( $title, $expectedContentModel ) {
|
||||
$title = Title::newFromText( $title );
|
||||
LinkCache::singleton()->addBadLinkObj( $title );
|
||||
MediaWikiServices::getInstance()->getLinkCache()->addBadLinkObj( $title );
|
||||
$handler = ContentHandler::getForTitle( $title );
|
||||
$this->assertEquals( $expectedContentModel, $handler->getModelID() );
|
||||
}
|
||||
|
|
@ -158,7 +158,7 @@ class ContentHandlerTest extends MediaWikiTestCase {
|
|||
public function testGetPageLanguage( $title, $expected ) {
|
||||
if ( is_string( $title ) ) {
|
||||
$title = Title::newFromText( $title );
|
||||
LinkCache::singleton()->addBadLinkObj( $title );
|
||||
MediaWikiServices::getInstance()->getLinkCache()->addBadLinkObj( $title );
|
||||
}
|
||||
|
||||
$expected = wfGetLangObj( $expected );
|
||||
|
|
@ -308,7 +308,7 @@ class ContentHandlerTest extends MediaWikiTestCase {
|
|||
$expectedModelId, $expectedNativeData, $shouldFail
|
||||
) {
|
||||
$title = Title::newFromText( $title );
|
||||
LinkCache::singleton()->addBadLinkObj( $title );
|
||||
MediaWikiServices::getInstance()->getLinkCache()->addBadLinkObj( $title );
|
||||
try {
|
||||
$content = ContentHandler::makeContent( $data, $title, $modelId, $format );
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue