if ( $wgEnablePersistentLC ) {
// Purge related entries in links cache on new page, to heal broken links
- $ptitle = wfStrencode( $ttl );
- wfQuery("DELETE linkscc FROM linkscc,brokenlinks ".
- "WHERE lcc_pageid=bl_from AND bl_to='{$ptitle}'", DB_WRITE);
+ LinkCache::linksccClearBrokenLinksTo( $ttl );
}
$sql = "INSERT INTO recentchanges (rc_timestamp,rc_cur_time," .
global $wgEnablePersistentLC;
if ( $wgEnablePersistentLC ) {
// Purge link cache for this page
- $pageid=$this->getID();
- wfQuery("DELETE FROM linkscc WHERE lcc_pageid='{$pageid}'", DB_WRITE);
- }
+ LinkCache::linksccClearPage( $this->getID() );
+ }
}
if( $wgDBtransactions ) {
if ( $wgEnablePersistentLC ) {
// Purge related entries in links cache on delete,
- wfQuery("DELETE linkscc FROM linkscc,links ".
- "WHERE lcc_title=links.l_from AND l_to={$id}", DB_WRITE);
- wfQuery("DELETE FROM linkscc WHERE lcc_title='{$t}'", DB_WRITE);
+ LinkCache::linksccClearLinksTo( $id );
}
$sql = "SELECT l_from FROM links WHERE l_to={$id}";
global $wgEnablePersistentLC;
if ( $wgEnablePersistentLC ) {
- wfQuery("DELETE FROM linkscc WHERE lcc_pageid='{$pid}'", DB_WRITE);
+ LinkCache::linksccClearPage( $pid );
}
-
-
+
$wgOut->returnToMain( false );
}
$dbkeyfrom = wfStrencode( $fromtitle->getPrefixedDBKey() );
if ( $wgEnablePersistentLC ) {
- $cc =& $this->getFromLinkscc( $dbkeyfrom );
- if( $cc != FALSE ){
- $this->mOldGoodLinks = $this->mGoodLinks = $cc->mGoodLinks;
- $this->mOldBadLinks = $this->mBadLinks = $cc->mBadLinks;
- $this->mPreFilled = true;
- wfProfileOut( $fname );
- wfDebug( "LinkCache::preFill - got from linkscc\n" );
+ if( $this->fillFromLinkscc( $dbkeyfrom ) ){
return;
- }
+ }
}
-
$sql = "SELECT cur_id,cur_namespace,cur_title
FROM cur,links
WHERE cur_id=l_to AND l_from='{$dbkeyfrom}'";
$this->mPreFilled = true;
if ( $wgEnablePersistentLC ) {
- // put fetched link data into cache
- if( $wgCompressedPersistentLC and function_exists( "gzcompress" ) ) {
- $ser = wfStrencode( gzcompress( serialize( $this ), 3 ));
- } else {
- $ser = wfStrencode( serialize( $this ) );
- }
- wfQuery("REPLACE INTO linkscc(lcc_pageid,lcc_title,lcc_cacheobj) VALUES({$id}, '{$dbkeyfrom}', '{$ser}')",
- DB_WRITE);
- wfDebug( "$fname - saved to linkscc\n" );
+ $this->saveToLinkscc( $id, $dbkeyfrom );
}
-
wfProfileOut( $fname );
}
$this->mImageLinks = array();
}
-
- function &getFromLinkscc( $dbkeyfrom ){
+ /* private */ function fillFromLinkscc( $dbkeyfrom ){
$res = wfQuery("SELECT lcc_cacheobj FROM linkscc WHERE lcc_title = '{$dbkeyfrom}'",
DB_READ);
$row = wfFetchObject( $res );
}
$cc = @unserialize( $cacheobj );
if( isset( $cc->mClassVer ) and ($cc->mClassVer == $this->mClassVer ) ){
- return $cc;
+ $this->mOldGoodLinks = $this->mGoodLinks = $cc->mGoodLinks;
+ $this->mOldBadLinks = $this->mBadLinks = $cc->mBadLinks;
+ $this->mPreFilled = true;
+ return TRUE;
} else {
return FALSE;
}
+
+ }
+
+ /* private */ function saveToLinkscc( $pid, $dbkeyfrom ){
+ if( $wgCompressedPersistentLC and function_exists( "gzcompress" ) ) {
+ $ser = wfStrencode( gzcompress( serialize( $this ), 3 ));
+ } else {
+ $ser = wfStrencode( serialize( $this ) );
+ }
+ wfQuery("REPLACE INTO linkscc(lcc_pageid,lcc_title,lcc_cacheobj) " .
+ "VALUES({$pid}, '{$dbkeyfrom}', '{$ser}')", DB_WRITE);
+ }
+
+ # $pid is a page id
+ /* static */ function linksccClearLinksTo( $pid ){
+ $pid = intval( $pid );
+ wfQuery("DELETE linkscc FROM linkscc,links ".
+ "WHERE lcc_title=links.l_from AND l_to={$pid}", DB_WRITE);
+ wfQuery("DELETE FROM linkscc WHERE lcc_pageid='{$pid}'", DB_WRITE);
+ }
+
+ # $title is a prefixed db title, for example like Title->getPrefixedDBkey() returns.
+ /* static */ function linksccClearBrokenLinksTo( $title ){
+ $title = wfStrencode( $title );
+ wfQuery("DELETE linkscc FROM linkscc,brokenlinks ".
+ "WHERE lcc_pageid=bl_from AND bl_to='{$title}'", DB_WRITE);
+ }
+
+ # $pid is a page id
+ /* static */ function linksccClearPage( $pid ){
+ $id = intval( $pid );
+ wfQuery("DELETE FROM linkscc WHERE lcc_pageid='{$pid}'", DB_WRITE);
}
}
?>