);
# Add the results to the link cache
- $lb->addResultToCache( LinkCache::singleton(), $res );
+ $linkCache = MediaWikiServices::getInstance()->getLinkCache();
+ $lb->addResultToCache( $linkCache, $res );
return $res;
}
&& ( !$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' );
}
$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 );
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 ) {
$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 ) {
$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 ) {
* @param int $newid The new Article ID
*/
public function resetArticleID( $newid ) {
- $linkCache = LinkCache::singleton();
+ $linkCache = MediaWikiServices::getInstance()->getLinkCache();
$linkCache->clearLink( $this );
if ( $newid === false ) {
}
public static function clearCaches() {
- $linkCache = LinkCache::singleton();
+ $linkCache = MediaWikiServices::getInstance()->getLinkCache();
$linkCache->clear();
$titleCache = self::getTitleCache();
$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 ) {
);
$retVal = [];
- $linkCache = LinkCache::singleton();
+ $linkCache = MediaWikiServices::getInstance()->getLinkCache();
foreach ( $res as $row ) {
if ( $row->page_id ) {
$titleObj = self::newFromRow( $row );
// 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' );
}
// 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;
// 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 );
$hiddencats[$row->page_title] = isset( $row->pp_propname );
}
- $linkCache = LinkCache::singleton();
+ $linkCache = MediaWikiServices::getInstance()->getLinkCache();
foreach ( $links as $link => $sortkey ) {
$entry = [];
* 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 ) {
$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,
}
// 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 ) {
* @ingroup Parser
*/
+use MediaWiki\MediaWikiServices;
+
/**
* @ingroup Parser
*/
global $wgContLang;
$colours = [];
- $linkCache = LinkCache::singleton();
+ $linkCache = MediaWikiServices::getInstance()->getLinkCache();
$output = $this->parent->getOutput();
$linkRenderer = $this->parent->getLinkRenderer();
$linkBatch = new LinkBatch();
$variantMap = []; // maps $pdbkey_Variant => $keys (of link holders)
$output = $this->parent->getOutput();
- $linkCache = LinkCache::singleton();
+ $linkCache = MediaWikiServices::getInstance()->getLinkCache();
$titlesToBeConverted = '';
$titlesAttrs = [];
$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 );
}
* @file
* @ingroup Parser
*/
+
+use MediaWiki\MediaWikiServices;
use Wikimedia\ScopedCallback;
/**
};
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 );
} );
}
}
* @ingroup Maintenance
*/
+use MediaWiki\MediaWikiServices;
use Wikimedia\Rdbms\IDatabase;
require_once __DIR__ . '/Maintenance.php';
public static function fixLinksFromArticle( $id, $ns = false ) {
$page = WikiPage::newFromID( $id );
- LinkCache::singleton()->clear();
+ MediaWikiServices::getInstance()->getLinkCache()->clear();
if ( $page === null ) {
return;
// 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();
if ( $tbl === 'page' ) {
// Forget about the pages since they don't
// exist in the DB.
- LinkCache::singleton()->clear();
+ MediaWikiServices::getInstance()->getLinkCache()->clear();
}
}
}
if ( $tbl === 'page' ) {
// Forget about the pages since they don't
// exist in the DB.
- LinkCache::singleton()->clear();
+ MediaWikiServices::getInstance()->getLinkCache()->clear();
}
}
<?php
+use MediaWiki\MediaWikiServices;
+
/**
* @group ContentHandler
* @group Database
* @covers Title::clearCaches
*/
public function testClearCaches() {
- $linkCache = LinkCache::singleton();
+ $linkCache = MediaWikiServices::getInstance()->getLinkCache();
$title1 = Title::newFromText( 'Foo' );
$linkCache->addGoodLinkObj( 23, $title1 );
<?php
+use MediaWiki\MediaWikiServices;
+
/**
* @group Database
* @group Title
*/
public function testExists() {
$title = Title::makeTitle( NS_PROJECT, 'New page' );
- $linkCache = LinkCache::singleton();
+ $linkCache = MediaWikiServices::getInstance()->getLinkCache();
$article = new Article( $title );
$page = $article->getPage();
*/
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() );
}
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 );
$expectedModelId, $expectedNativeData, $shouldFail
) {
$title = Title::newFromText( $title );
- LinkCache::singleton()->addBadLinkObj( $title );
+ MediaWikiServices::getInstance()->getLinkCache()->addBadLinkObj( $title );
try {
$content = ContentHandler::makeContent( $data, $title, $modelId, $format );