From f2a59db33f33f34a28704b9a47686d6d32abc0bc Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Thu, 5 Jan 2006 02:05:53 +0000 Subject: [PATCH] Removed $wgLinkCache, converted to a singleton. Removed obsolete cruft from LinkCache.php. --- docs/globals.txt | 3 - includes/Image.php | 4 +- includes/LinkBatch.php | 13 ++- includes/LinkCache.php | 142 ++++------------------- includes/OutputPage.php | 4 +- includes/Parser.php | 17 +-- includes/Setup.php | 1 - includes/Skin.php | 11 +- includes/SpecialImport.php | 4 +- includes/SpecialListusers.php | 4 +- includes/SpecialLog.php | 10 +- includes/SpecialMostlinkedcategories.php | 4 +- includes/SpecialRecentchanges.php | 3 +- includes/SpecialWantedcategories.php | 4 +- includes/SpecialWantedpages.php | 4 +- includes/Title.php | 37 +++--- maintenance/cleanupTitles.php | 4 +- maintenance/dumpHTML.inc | 8 +- 18 files changed, 81 insertions(+), 196 deletions(-) diff --git a/docs/globals.txt b/docs/globals.txt index b36f8ea3c8..ecc5ab33fd 100644 --- a/docs/globals.txt +++ b/docs/globals.txt @@ -66,9 +66,6 @@ $wgContLang $wgArticle Article object corresponding to $wgTitle. -$wgLinkCache - LinkCache object. - $wgParser Parser object. Parser extensions register their hooks here. diff --git a/includes/Image.php b/includes/Image.php index 64e897d267..9a0d055c5a 100644 --- a/includes/Image.php +++ b/includes/Image.php @@ -1453,7 +1453,6 @@ class Image * This is mostly copied from Title::getLinksTo() */ function getLinksTo( $options = '' ) { - global $wgLinkCache; $fname = 'Image::getLinksTo'; wfProfileIn( $fname ); @@ -1462,6 +1461,7 @@ class Image } else { $db =& wfGetDB( DB_SLAVE ); } + $linkCache =& LinkCache::singleton(); extract( $db->tableNames( 'page', 'imagelinks' ) ); $encName = $db->addQuotes( $this->name ); @@ -1472,7 +1472,7 @@ class Image if ( $db->numRows( $res ) ) { while ( $row = $db->fetchObject( $res ) ) { if ( $titleObj = Title::makeTitle( $row->page_namespace, $row->page_title ) ) { - $wgLinkCache->addGoodLinkObj( $row->page_id, $titleObj ); + $linkCache->addGoodLinkObj( $row->page_id, $titleObj ); $retVal[] = $titleObj; } } diff --git a/includes/LinkBatch.php b/includes/LinkBatch.php index 7586cbc2f9..3c0eb1e9bd 100644 --- a/includes/LinkBatch.php +++ b/includes/LinkBatch.php @@ -45,12 +45,21 @@ class LinkBatch { function setArray( $array ) { $this->data = $array; } + + /** + * Do the query and add the results to the LinkCache object + * Return an array mapping PDBK to ID + */ + function execute() { + $linkCache =& LinkCache::singleton(); + $this->executeInto( $linkCache ); + } /** - * Do the query and add the results to a LinkCache object + * Do the query and add the results to a given LinkCache object * Return an array mapping PDBK to ID */ - function execute( &$cache ) { + function executeInto( &$cache ) { $fname = 'LinkBatch::execute'; wfProfileIn( $fname ); // Do query diff --git a/includes/LinkCache.php b/includes/LinkCache.php index da2a864650..f262110289 100644 --- a/includes/LinkCache.php +++ b/includes/LinkCache.php @@ -5,15 +5,6 @@ * @subpackage Cache */ -/** - * - */ -# These are used in incrementalSetup() -define ('LINKCACHE_GOOD', 0); -define ('LINKCACHE_BAD', 1); -define ('LINKCACHE_IMAGE', 2); -define ('LINKCACHE_PAGE', 3); - /** * @package MediaWiki * @subpackage Cache @@ -24,28 +15,30 @@ class LinkCache { /* private */ var $mClassVer = 3; /* private */ var $mPageLinks; - /* private */ var $mGoodLinks, $mBadLinks, $mActive; - /* private */ var $mImageLinks, $mCategoryLinks; - /* private */ var $mPreFilled, $mOldGoodLinks, $mOldBadLinks; + /* private */ var $mGoodLinks, $mBadLinks; /* private */ var $mForUpdate; - /* private */ function getKey( $title ) { - global $wgDBname; - return $wgDBname.':lc:title:'.$title; + /** + * Get an instance of this class + */ + function &singleton() { + static $instance; + if ( !isset( $instance ) ) { + $instance = new LinkCache; + } + return $instance; } function LinkCache() { - $this->mActive = true; - $this->mPreFilled = false; $this->mForUpdate = false; $this->mPageLinks = array(); $this->mGoodLinks = array(); $this->mBadLinks = array(); - $this->mImageLinks = array(); - $this->mCategoryLinks = array(); - $this->mOldGoodLinks = array(); - $this->mOldBadLinks = array(); - $this->mOldPageLinks = array(); + } + + /* private */ function getKey( $title ) { + global $wgDBname; + return $wgDBname.':lc:title:'.$title; } /** @@ -68,37 +61,19 @@ class LinkCache { } function addGoodLinkObj( $id, $title ) { - if ( $this->mActive ) { - $dbkey = $title->getPrefixedDbKey(); - $this->mGoodLinks[$dbkey] = $id; - $this->mPageLinks[$dbkey] = $title; - } + $dbkey = $title->getPrefixedDbKey(); + $this->mGoodLinks[$dbkey] = $id; + $this->mPageLinks[$dbkey] = $title; } function addBadLinkObj( $title ) { $dbkey = $title->getPrefixedDbKey(); - if ( $this->mActive && ( ! $this->isBadLink( $dbkey ) ) ) { + if ( ! $this->isBadLink( $dbkey ) ) { $this->mBadLinks[$dbkey] = 1; $this->mPageLinks[$dbkey] = $title; } } - function addImageLink( $title ) { - if ( $this->mActive ) { $this->mImageLinks[$title] = 1; } - } - - function addImageLinkObj( $nt ) { - if ( $this->mActive ) { $this->mImageLinks[$nt->getDBkey()] = 1; } - } - - function addCategoryLink( $title, $sortkey ) { - if ( $this->mActive ) { $this->mCategoryLinks[$title] = $sortkey; } - } - - function addCategoryLinkObj( &$nt, $sortkey ) { - $this->addCategoryLink( $nt->getDBkey(), $sortkey ); - } - function clearBadLink( $title ) { unset( $this->mBadLinks[$title] ); $this->clearLink( $title ); @@ -110,17 +85,10 @@ class LinkCache { $wgMemc->delete( $this->getKey( $title ) ); } - /** @deprecated */ - function suspend() { $this->mActive = false; } - /** @deprecated */ - function resume() { $this->mActive = true; } - function getPageLinks() { return $this->mPageLinks; } function getGoodLinks() { return $this->mGoodLinks; } function getBadLinks() { return array_keys( $this->mBadLinks ); } - function getImageLinks() { return $this->mImageLinks; } - function getCategoryLinks() { return $this->mCategoryLinks; } - + /** * Add a title to the link cache, return the page_id or zero if non-existent * @param string $title Title to add @@ -198,60 +166,6 @@ class LinkCache { return $id; } - /** - * Bulk-check the pagelinks and page arrays for existence info. - * @param Title $fromtitle - * @deprecated - */ - function preFill( &$fromtitle ) { - global $wgAntiLockFlags; - $fname = 'LinkCache::preFill'; - wfProfileIn( $fname ); - - $this->suspend(); - $id = $fromtitle->getArticleID(); - $this->resume(); - - if( $id == 0 ) { - wfDebug( "$fname - got id 0 for title '" . $fromtitle->getPrefixedDBkey() . "'\n" ); - wfProfileOut( $fname ); - return; - } - - if ( $this->mForUpdate ) { - $db =& wfGetDB( DB_MASTER ); - if ( !( $wgAntiLockFlags & ALF_NO_LINK_LOCK ) ) { - $options = 'FOR UPDATE'; - } else { - $options = ''; - } - } else { - $db =& wfGetDB( DB_SLAVE ); - $options = ''; - } - - $page = $db->tableName( 'page' ); - $pagelinks = $db->tableName( 'pagelinks' ); - - $sql = "SELECT page_id,pl_namespace,pl_title - FROM $pagelinks - LEFT JOIN $page - ON pl_namespace=page_namespace AND pl_title=page_title - WHERE pl_from=$id $options"; - $res = $db->query( $sql, $fname ); - while( $s = $db->fetchObject( $res ) ) { - $title = Title::makeTitle( $s->pl_namespace, $s->pl_title ); - if( $s->page_id ) { - $this->addGoodLinkObj( $s->page_id, $title ); - } else { - $this->addBadLinkObj( $title ); - } - } - $this->mPreFilled = true; - - wfProfileOut( $fname ); - } - /** * Clears cache */ @@ -259,22 +173,6 @@ class LinkCache { $this->mPageLinks = array(); $this->mGoodLinks = array(); $this->mBadLinks = array(); - $this->mImageLinks = array(); - $this->mCategoryLinks = array(); - $this->mOldGoodLinks = array(); - $this->mOldBadLinks = array(); - $this->mOldPageLinks = array(); - } - - /** - * Swaps old and current link registers - * @deprecated - */ - function swapRegisters() { - swap( $this->mGoodLinks, $this->mOldGoodLinks ); - swap( $this->mBadLinks, $this->mOldBadLinks ); - swap( $this->mImageLinks, $this->mOldImageLinks ); - swap( $this->mPageLinks, $this->mOldPageLinks ); } } ?> diff --git a/includes/OutputPage.php b/includes/OutputPage.php index 9978a31799..45b28b694a 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -219,13 +219,13 @@ class OutputPage { * Add an array of categories, with names in the keys */ function addCategoryLinks($categories) { - global $wgUser, $wgLinkCache, $wgContLang; + global $wgUser, $wgContLang; # Add the links to the link cache in a batch $arr = array( NS_CATEGORY => $categories ); $lb = new LinkBatch; $lb->setArray( $arr ); - $lb->execute( $wgLinkCache ); + $lb->execute(); $sk =& $wgUser->getSkin(); foreach ( $categories as $category => $arbitrary ) { diff --git a/includes/Parser.php b/includes/Parser.php index bd48b22756..cd8fd80359 100644 --- a/includes/Parser.php +++ b/includes/Parser.php @@ -73,7 +73,7 @@ define( 'EXT_IMAGE_REGEX', * performs brace substitution on MediaWiki messages * * Globals used: - * objects: $wgLang, $wgLinkCache + * objects: $wgLang * * NOT $wgArticle, $wgUser or $wgTitle. Keep them away! * @@ -1222,7 +1222,7 @@ class Parser * @access private */ function replaceInternalLinks( $s ) { - global $wgContLang, $wgLinkCache; + global $wgContLang; static $fname = 'Parser::replaceInternalLinks' ; wfProfileIn( $fname ); @@ -3328,7 +3328,7 @@ class Parser * $options is a bit field, RLH_FOR_UPDATE to select for update */ function replaceLinkHolders( &$text, $options = 0 ) { - global $wgUser, $wgLinkCache; + global $wgUser; global $wgOutputReplace; $fname = 'Parser::replaceLinkHolders'; @@ -3336,7 +3336,8 @@ class Parser $pdbks = array(); $colours = array(); - $sk = $this->mOptions->getSkin(); + $sk =& $this->mOptions->getSkin(); + $linkCache =& LinkCache::singleton(); if ( !empty( $this->mLinkHolders['namespaces'] ) ) { wfProfileIn( $fname.'-check' ); @@ -3363,10 +3364,10 @@ class Parser # Check if it's a static known link, e.g. interwiki if ( $title->isAlwaysKnown() ) { $colours[$pdbk] = 1; - } elseif ( ( $id = $wgLinkCache->getGoodLinkID( $pdbk ) ) != 0 ) { + } elseif ( ( $id = $linkCache->getGoodLinkID( $pdbk ) ) != 0 ) { $colours[$pdbk] = 1; $this->mOutput->addLink( $title, $id ); - } elseif ( $wgLinkCache->isBadLink( $pdbk ) ) { + } elseif ( $linkCache->isBadLink( $pdbk ) ) { $colours[$pdbk] = 0; } else { # Not in the link cache, add it to the query @@ -3402,7 +3403,7 @@ class Parser while ( $s = $dbr->fetchObject($res) ) { $title = Title::makeTitle( $s->page_namespace, $s->page_title ); $pdbk = $title->getPrefixedDBkey(); - $wgLinkCache->addGoodLinkObj( $s->page_id, $title ); + $linkCache->addGoodLinkObj( $s->page_id, $title ); $this->mOutput->addLink( $title, $s->page_id ); if ( $threshold > 0 ) { @@ -3427,7 +3428,7 @@ class Parser $searchkey = ""; $title = $this->mLinkHolders['titles'][$key]; if ( empty( $colours[$pdbk] ) ) { - $wgLinkCache->addBadLinkObj( $title ); + $linkCache->addBadLinkObj( $title ); $colours[$pdbk] = 0; $this->mOutput->addLink( $title, 0 ); $wgOutputReplace[$searchkey] = $sk->makeBrokenLinkObj( $title, diff --git a/includes/Setup.php b/includes/Setup.php index 7409998ec7..5ea7ef9d27 100644 --- a/includes/Setup.php +++ b/includes/Setup.php @@ -279,7 +279,6 @@ wfProfileIn( $fname.'-misc2' ); $wgDeferredUpdateList = array(); $wgPostCommitUpdateList = array(); -$wgLinkCache = new LinkCache(); $wgMagicWords = array(); $wgMwRedir =& MagicWord::get( MAG_REDIRECT ); $wgParserCache = new ParserCache( $messageMemc ); diff --git a/includes/Skin.php b/includes/Skin.php index 58007b8348..deef5f3945 100644 --- a/includes/Skin.php +++ b/includes/Skin.php @@ -1276,13 +1276,10 @@ END; } function dateLink() { - global $wgLinkCache; $t1 = Title::newFromText( gmdate( 'F j' ) ); $t2 = Title::newFromText( gmdate( 'Y' ) ); - $wgLinkCache->suspend(); $id = $t1->getArticleID(); - $wgLinkCache->resume(); if ( 0 == $id ) { $s = $this->makeBrokenLink( $t1->getText() ); @@ -1291,9 +1288,7 @@ END; } $s .= ', '; - $wgLinkCache->suspend(); $id = $t2->getArticleID(); - $wgLinkCache->resume(); if ( 0 == $id ) { $s .= $this->makeBrokenLink( $t2->getText() ); @@ -1304,7 +1299,7 @@ END; } function talkLink() { - global $wgTitle, $wgLinkCache; + global $wgTitle; if ( NS_SPECIAL == $wgTitle->getNamespace() ) { # No discussion links for special pages @@ -1334,15 +1329,13 @@ END; $text = wfMsg( 'talkpage' ); } - $wgLinkCache->suspend(); $s = $this->makeLinkObj( $link, $text ); - $wgLinkCache->resume(); return $s; } function commentLink() { - global $wgContLang, $wgTitle, $wgLinkCache; + global $wgContLang, $wgTitle; if ( $wgTitle->getNamespace() == NS_SPECIAL ) { return ''; diff --git a/includes/SpecialImport.php b/includes/SpecialImport.php index 37a4bc9010..81eb9c9537 100644 --- a/includes/SpecialImport.php +++ b/includes/SpecialImport.php @@ -197,8 +197,8 @@ class WikiRevision { } // avoid memory leak...? - global $wgLinkCache; - $wgLinkCache->clear(); + $linkCache =& LinkCache::singleton(); + $linkCache->clear(); $article = new Article( $this->title ); $pageId = $article->getId(); diff --git a/includes/SpecialListusers.php b/includes/SpecialListusers.php index 49a3c11b8d..0fa91e571b 100644 --- a/includes/SpecialListusers.php +++ b/includes/SpecialListusers.php @@ -57,13 +57,11 @@ class ListUsersPage extends QueryPage { * Fetch user page links and cache their existence */ function preprocessResults( &$db, &$res ) { - global $wgLinkCache; - $batch = new LinkBatch; while ( $row = $db->fetchObject( $res ) ) { $batch->addObj( Title::makeTitleSafe( $row->namespace, $row->title ) ); } - $batch->execute( $wgLinkCache ); + $batch->execute(); // Back to start for display if( $db->numRows( $res ) > 0 ) { diff --git a/includes/SpecialLog.php b/includes/SpecialLog.php index 9e747d4b23..1b6c98e81f 100644 --- a/includes/SpecialLog.php +++ b/includes/SpecialLog.php @@ -241,7 +241,6 @@ class LogViewer { * @return object database result set */ function getLogRows() { - global $wgLinkCache; $result = $this->reader->getRows(); $this->numResults = 0; @@ -260,7 +259,7 @@ class LogViewer { } ++$this->numResults; } - $batch->execute( $wgLinkCache ); + $batch->execute(); return $result; } @@ -298,17 +297,18 @@ class LogViewer { * @private */ function logLine( $s ) { - global $wgLang, $wgLinkCache; + global $wgLang; $title = Title::makeTitle( $s->log_namespace, $s->log_title ); $user = Title::makeTitleSafe( NS_USER, $s->user_name ); $time = $wgLang->timeanddate( wfTimestamp(TS_MW, $s->log_timestamp), true ); // Enter the existence or non-existence of this page into the link cache, // for faster makeLinkObj() in LogPage::actionText() + $linkCache =& LinkCache::singleton(); if( $s->page_id ) { - $wgLinkCache->addGoodLinkObj( $s->page_id, $title ); + $linkCache->addGoodLinkObj( $s->page_id, $title ); } else { - $wgLinkCache->addBadLinkObj( $title ); + $linkCache->addBadLinkObj( $title ); } $userLink = $this->skin->makeLinkObj( $user, htmlspecialchars( $s->user_name ) ); diff --git a/includes/SpecialMostlinkedcategories.php b/includes/SpecialMostlinkedcategories.php index 84cac96fc6..e733177a9b 100644 --- a/includes/SpecialMostlinkedcategories.php +++ b/includes/SpecialMostlinkedcategories.php @@ -45,12 +45,10 @@ class MostlinkedCategoriesPage extends QueryPage { * Fetch user page links and cache their existence */ function preprocessResults( &$db, &$res ) { - global $wgLinkCache; - $batch = new LinkBatch; while ( $row = $db->fetchObject( $res ) ) $batch->addObj( Title::makeTitleSafe( $row->namespace, $row->title ) ); - $batch->execute( $wgLinkCache ); + $batch->execute(); // Back to start for display if ( $db->numRows( $res ) > 0 ) diff --git a/includes/SpecialRecentchanges.php b/includes/SpecialRecentchanges.php index ac4a8c5077..634aed93de 100644 --- a/includes/SpecialRecentchanges.php +++ b/includes/SpecialRecentchanges.php @@ -18,7 +18,6 @@ require_once( 'Revision.php' ); function wfSpecialRecentchanges( $par, $specialPage ) { global $wgUser, $wgOut, $wgRequest, $wgUseRCPatrol; global $wgRCShowWatchingUsers, $wgShowUpdatedMarker; - global $wgLinkCache; $fname = 'wfSpecialRecentchanges'; # Get query parameters @@ -168,7 +167,7 @@ function wfSpecialRecentchanges( $par, $specialPage ) { # Web output... // Run existence checks - $batch->execute( $wgLinkCache ); + $batch->execute(); // Output header if ( !$specialPage->including() ) { diff --git a/includes/SpecialWantedcategories.php b/includes/SpecialWantedcategories.php index a4f8020429..4ac6666c00 100644 --- a/includes/SpecialWantedcategories.php +++ b/includes/SpecialWantedcategories.php @@ -47,12 +47,10 @@ class WantedCategoriesPage extends QueryPage { * Fetch user page links and cache their existence */ function preprocessResults( &$db, &$res ) { - global $wgLinkCache; - $batch = new LinkBatch; while ( $row = $db->fetchObject( $res ) ) $batch->addObj( Title::makeTitleSafe( $row->namespace, $row->title ) ); - $batch->execute( $wgLinkCache ); + $batch->execute(); // Back to start for display if ( $db->numRows( $res ) > 0 ) diff --git a/includes/SpecialWantedpages.php b/includes/SpecialWantedpages.php index 5c51083dad..7e5685c4fd 100644 --- a/includes/SpecialWantedpages.php +++ b/includes/SpecialWantedpages.php @@ -53,12 +53,10 @@ class WantedPagesPage extends QueryPage { * Fetch user page links and cache their existence */ function preprocessResults( &$db, &$res ) { - global $wgLinkCache; - $batch = new LinkBatch; while ( $row = $db->fetchObject( $res ) ) $batch->addObj( Title::makeTitleSafe( $row->namespace, $row->title ) ); - $batch->execute( $wgLinkCache ); + $batch->execute(); // Back to start for display if ( $db->numRows( $res ) > 0 ) diff --git a/includes/Title.php b/includes/Title.php index 44ba6cf12c..47b877c04b 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -1099,14 +1099,14 @@ class Title { * @access public */ function getArticleID( $flags = 0 ) { - global $wgLinkCache; + $linkCache =& LinkCache::singleton(); if ( $flags & GAID_FOR_UPDATE ) { - $oldUpdate = $wgLinkCache->forUpdate( true ); - $this->mArticleID = $wgLinkCache->addLinkObj( $this ); - $wgLinkCache->forUpdate( $oldUpdate ); + $oldUpdate = $linkCache->forUpdate( true ); + $this->mArticleID = $linkCache->addLinkObj( $this ); + $linkCache->forUpdate( $oldUpdate ); } else { if ( -1 == $this->mArticleID ) { - $this->mArticleID = $wgLinkCache->addLinkObj( $this ); + $this->mArticleID = $linkCache->addLinkObj( $this ); } } return $this->mArticleID; @@ -1125,7 +1125,7 @@ class Title { /** * This clears some fields in this object, and clears any associated - * keys in the "bad links" section of $wgLinkCache. + * keys in the "bad links" section of the link cache. * * - This is called from Article::insertNewArticle() to allow * loading of the new page_id. It's also called from @@ -1135,8 +1135,8 @@ class Title { * @access public */ function resetArticleID( $newid ) { - global $wgLinkCache; - $wgLinkCache->clearBadLink( $this->getPrefixedDBkey() ); + $linkCache =& LinkCache::singleton(); + $linkCache->clearBadLink( $this->getPrefixedDBkey() ); if ( 0 == $newid ) { $this->mArticleID = -1; } else { $this->mArticleID = $newid; } @@ -1401,7 +1401,7 @@ class Title { * @access public */ function getLinksTo( $options = '', $table = 'pagelinks', $prefix = 'pl' ) { - global $wgLinkCache; + $linkCache =& LinkCache::singleton(); $id = $this->getArticleID(); if ( $options ) { @@ -1423,7 +1423,7 @@ class Title { if ( $db->numRows( $res ) ) { while ( $row = $db->fetchObject( $res ) ) { if ( $titleObj = Title::makeTitle( $row->page_namespace, $row->page_title ) ) { - $wgLinkCache->addGoodLinkObj( $row->page_id, $titleObj ); + $linkCache->addGoodLinkObj( $row->page_id, $titleObj ); $retVal[] = $titleObj; } } @@ -1452,8 +1452,6 @@ class Title { * @access public */ function getBrokenLinksFrom( $options = '' ) { - global $wgLinkCache; - if ( $options ) { $db =& wfGetDB( DB_MASTER ); } else { @@ -1642,7 +1640,7 @@ class Title { * @access private */ function moveOverExistingRedirect( &$nt, $reason = '' ) { - global $wgUser, $wgLinkCache, $wgUseSquid, $wgMwRedir; + global $wgUser, $wgUseSquid, $wgMwRedir; $fname = 'Title::moveOverExistingRedirect'; $comment = wfMsgForContent( '1movedto2', $this->getPrefixedText(), $nt->getPrefixedText() ); @@ -1655,6 +1653,7 @@ class Title { $newid = $nt->getArticleID(); $oldid = $this->getArticleID(); $dbw =& wfGetDB( DB_MASTER ); + $linkCache =& LinkCache::singleton(); # Delete the old redirect. We don't save it to history since # by definition if we've got here it's rather uninteresting. @@ -1679,7 +1678,7 @@ class Title { /* WHERE */ array( 'page_id' => $oldid ), $fname ); - $wgLinkCache->clearLink( $nt->getPrefixedDBkey() ); + $linkCache->clearLink( $nt->getPrefixedDBkey() ); # Recreate the redirect, this time in the other direction. $redirectText = $wgMwRedir->getSynonym( 0 ) . ' [[' . $nt->getPrefixedText() . "]]\n"; @@ -1691,7 +1690,7 @@ class Title { 'text' => $redirectText ) ); $revid = $redirectRevision->insertOn( $dbw ); $redirectArticle->updateRevisionOn( $dbw, $redirectRevision, 0 ); - $wgLinkCache->clearLink( $this->getPrefixedDBkey() ); + $linkCache->clearLink( $this->getPrefixedDBkey() ); # Log the move $log = new LogPage( 'move' ); @@ -1722,7 +1721,7 @@ class Title { * @access private */ function moveToNewTitle( &$nt, &$newid, $reason = '' ) { - global $wgUser, $wgLinkCache, $wgUseSquid; + global $wgUser, $wgUseSquid; global $wgMwRedir; $fname = 'MovePageForm::moveToNewTitle'; $comment = wfMsgForContent( '1movedto2', $this->getPrefixedText(), $nt->getPrefixedText() ); @@ -1734,8 +1733,8 @@ class Title { $oldid = $this->getArticleID(); $dbw =& wfGetDB( DB_MASTER ); $now = $dbw->timestamp(); - wfSeedRandom(); $rand = wfRandom(); + $linkCache =& LinkCache::singleton(); # Save a null revision in the page's history notifying of the move $nullRevision = Revision::newNullRevision( $dbw, $oldid, @@ -1755,7 +1754,7 @@ class Title { $fname ); - $wgLinkCache->clearLink( $nt->getPrefixedDBkey() ); + $linkCache->clearLink( $nt->getPrefixedDBkey() ); # Insert redirect $redirectText = $wgMwRedir->getSynonym( 0 ) . ' [[' . $nt->getPrefixedText() . "]]\n"; @@ -1767,7 +1766,7 @@ class Title { 'text' => $redirectText ) ); $revid = $redirectRevision->insertOn( $dbw ); $redirectArticle->updateRevisionOn( $dbw, $redirectRevision, 0 ); - $wgLinkCache->clearLink( $this->getPrefixedDBkey() ); + $linkCache->clearLink( $this->getPrefixedDBkey() ); # Log the move $log = new LogPage( 'move' ); diff --git a/maintenance/cleanupTitles.php b/maintenance/cleanupTitles.php index 00da86f8d9..9280b87d2d 100644 --- a/maintenance/cleanupTitles.php +++ b/maintenance/cleanupTitles.php @@ -193,8 +193,8 @@ class TitleCleanup extends FiveUpgrade { ), array( 'page_id' => $row->page_id ), 'cleanupTitles::moveInconsistentPage' ); - global $wgLinkCache; - $wgLinkCache->clear(); + $linkCache =& LinkCache::singleton(); + $linkCache->clear(); } } diff --git a/maintenance/dumpHTML.inc b/maintenance/dumpHTML.inc index 589fb57e0b..3c6ddeba6b 100644 --- a/maintenance/dumpHTML.inc +++ b/maintenance/dumpHTML.inc @@ -193,8 +193,6 @@ class DumpHTML { } function doRedirects() { - global $wgLinkCache; - print "Doing redirects...\n"; $fname = 'DumpHTML::doRedirects'; $this->setupGlobals(); @@ -357,8 +355,10 @@ class DumpHTML { /** Reads the content of a title object, executes the skin and captures the result */ function getArticleHTML( &$title ) { - global $wgOut, $wgTitle, $wgArticle, $wgUser, $wgLinkCache; + global $wgOut, $wgTitle, $wgArticle, $wgUser; + $linkCache =& LinkCache::singleton(); + $linkCache->clear(); $wgTitle = $title; if ( is_null( $wgTitle ) ) { return false; @@ -368,7 +368,6 @@ class DumpHTML { if ( $ns == NS_SPECIAL ) { $wgOut = new OutputPage; $wgOut->setParserOptions( new ParserOptions ); - $wgLinkCache = new LinkCache; SpecialPage::executePath( $wgTitle ); } else { if ( $ns == NS_IMAGE ) { @@ -384,7 +383,6 @@ class DumpHTML { } else { $wgOut = new OutputPage; $wgOut->setParserOptions( new ParserOptions ); - $wgLinkCache = new LinkCache; $wgArticle->view(); } -- 2.20.1