/* private */ var $mImageLinks;
/* private */ var $mPreFilled, $mOldGoodLinks, $mOldBadLinks;
+ /* private */ function getKey( $title ) {
+ global $wgDBname;
+ return "$wgDBname:lc:title:$title";
+ }
+
function LinkCache()
{
$this->mActive = true;
if ( $this->mActive ) { $this->mImageLinks[$title] = 1; }
}
+ function addImageLinkObj( $nt )
+ {
+ if ( $this->mActive ) { $this->mImageLinks[$nt->getDBkey()] = 1; }
+ }
+
function clearBadLink( $title )
{
$index = array_search( $title, $this->mBadLinks );
if ( isset( $index ) ) {
unset( $this->mBadLinks[$index] );
}
- global $wgMemc, $wgDBname;
- $wgMemc->delete( "$wgDBname:lc:title:$title" );
+ $this->clearLink( $title );
+ }
+
+ function clearLink( $title ) {
+ global $wgMemc;
+ $wgMemc->delete( $this->getKey( $title ) );
}
function suspend() { $this->mActive = false; }
function addLink( $title )
{
- return $this->addLinkObj( Title::newFromDBkey( $title ) );
+ $nt = Title::newFromDBkey( $title );
+ if( $nt ) {
+ return $this->addLinkObj( $nt );
+ } else {
+ return 0;
+ }
}
function addLinkObj( &$nt )
{
- $title = $nt->getDBkey();
+ $title = $nt->getPrefixedDBkey();
if ( $this->isBadLink( $title ) ) { return 0; }
$id = $this->getGoodLinkID( $title );
if ( 0 != $id ) { return $id; }
- global $wgMemc, $wgDBname;
- $fname = "LinkCache::addLink-checkdatabase";
+ global $wgMemc;
+ $fname = "LinkCache::addLinkObj";
wfProfileIn( $fname );
$ns = $nt->getNamespace();
+ $t = $nt->getDBkey();
if ( "" == $title ) {
wfProfileOut( $fname );
return 0;
}
- $id = $wgMemc->get( $key = "$wgDBname:lc:title:$title" );
+ $id = $wgMemc->get( $key = $this->getKey( $title ) );
if( $id === FALSE ) {
- $sql = "SELECT HIGH_PRIORITY cur_id FROM cur WHERE cur_namespace=" .
- "{$ns} AND cur_title='" . wfStrencode( $title ) . "'";
+ $sql = "SELECT cur_id FROM cur WHERE cur_namespace=" .
+ "{$ns} AND cur_title='" . wfStrencode( $t ) . "'";
$res = wfQuery( $sql, DB_READ, "LinkCache::addLink" );
if ( 0 == wfNumRows( $res ) ) {
wfProfileIn( $fname );
# Note -- $fromtitle is a Title *object*
$dbkeyfrom = wfStrencode( $fromtitle->getPrefixedDBKey() );
- $sql = "SELECT HIGH_PRIORITY cur_id,cur_namespace,cur_title
+ $sql = "SELECT cur_id,cur_namespace,cur_title
FROM cur,links
WHERE cur_id=l_to AND l_from='{$dbkeyfrom}'";
- $res = wfQuery( $sql, DB_READ, "LinkCache::preFill" );
+ $res = wfQuery( $sql, DB_READ, $fname );
while( $s = wfFetchObject( $res ) ) {
$this->addGoodLink( $s->cur_id,
Title::makeName( $s->cur_namespace, $s->cur_title )
$id = $fromtitle->getArticleID();
$this->resume();
- $sql = "SELECT HIGH_PRIORITY bl_to
+ $sql = "SELECT bl_to
FROM brokenlinks
WHERE bl_from='{$id}'";
$res = wfQuery( $sql, DB_READ, "LinkCache::preFill" );
function moveOverExistingRedirect()
{
- global $wgUser;
+ global $wgUser, $wgLinkCache;
$fname = "MovePageForm::moveOverExistingRedirect";
$mt = wfMsg( "movedto" );
"cur_namespace={$this->nns},cur_title='{$this->ndt}' " .
"WHERE cur_id={$this->oldid}";
wfQuery( $sql, DB_WRITE, $fname );
+ $wgLinkCache->clearLink( $this->nft );
$sql = "UPDATE cur SET cur_touched='{$now}'," .
"cur_namespace={$this->ons},cur_title='{$this->odt}'," .
"cur_user_text='" . wfStrencode( $wgUser->getName() ) . "'," .
"cur_is_redirect=1,cur_is_new=0 WHERE cur_id={$this->newid}";
wfQuery( $sql, DB_WRITE, $fname );
+ $wgLinkCache->clearLink( $this->oft );
$sql = "UPDATE old SET " .
"old_namespace={$this->nns},old_title='{$this->ndt}' WHERE " .
function moveToNewTitle()
{
- global $wgUser;
+ global $wgUser, $wgLinkCache;
$fname = "MovePageForm::moveToNewTitle";
$mt = wfMsg( "movedto" );
"cur_namespace={$this->nns},cur_title='{$this->ndt}' " .
"WHERE cur_id={$this->oldid}";
wfQuery( $sql, DB_WRITE, $fname );
+ $wgLinkCache->clearLink( $this->nft );
$common = "{$this->ons},'{$this->odt}'," .
"'{$mt} \\\"{$this->nft}\\\"','" .
"VALUES ({$common},'{$won}','{$now}','#REDIRECT [[{$this->nft}]]\n',1,1)";
wfQuery( $sql, DB_WRITE, $fname );
$this->newid = wfInsertId();
+ $wgLinkCache->clearLink( $this->oft );
$sql = "UPDATE old SET " .
"old_namespace={$this->nns},old_title='{$this->ndt}' WHERE " .