- }
-
- $sql = "SELECT cur_id,cur_namespace,cur_title
- FROM cur,links
- WHERE cur_id=l_to AND l_from=$id";
- $res = wfQuery( $sql, DB_READ, $fname );
- while( $s = wfFetchObject( $res ) ) {
- $this->addGoodLink( $s->cur_id,
- Title::makeName( $s->cur_namespace, $s->cur_title )
- );
- }
-
- $sql = "SELECT bl_to
- FROM brokenlinks
- WHERE bl_from='{$id}'";
- $res = wfQuery( $sql, DB_READ, "LinkCache::preFill" );
- while( $s = wfFetchObject( $res ) ) {
- $this->addBadLink( $s->bl_to );
- }
-
- $this->mOldBadLinks = $this->mBadLinks;
- $this->mOldGoodLinks = $this->mGoodLinks;
- $this->mPreFilled = true;
-
- if ( $wgEnablePersistentLC ) {
- $this->saveToLinkscc( $id );
- }
- wfProfileOut( $fname );
- }
-
- function getGoodAdditions()
- {
- return array_diff( $this->mGoodLinks, $this->mOldGoodLinks );
- }
-
- function getBadAdditions()
- {
- #wfDebug( "mOldBadLinks: " . implode( ', ', array_keys( $this->mOldBadLinks ) ) . "\n" );
- #wfDebug( "mBadLinks: " . implode( ', ', array_keys( $this->mBadLinks ) ) . "\n" );
- return array_values( array_diff( array_keys( $this->mBadLinks ), array_keys( $this->mOldBadLinks ) ) );
- }
-
- function getImageAdditions()
- {
- return array_diff_assoc( $this->mImageLinks, $this->mOldImageLinks );
- }
-
- function getGoodDeletions()
- {
- return array_diff( $this->mOldGoodLinks, $this->mGoodLinks );
- }
-
- function getBadDeletions()
- {
- return array_values( array_diff( array_keys( $this->mOldBadLinks ), array_keys( $this->mBadLinks ) ));
- }
-
- function getImageDeletions()
- {
- return array_diff_assoc( $this->mOldImageLinks, $this->mImageLinks );
- }
-
- # Parameters: $which is one of the LINKCACHE_xxx constants, $del and $add are
- # the incremental update arrays which will be filled. Returns whether or not it's
- # worth doing the incremental version. For example, if [[List of mathematical topics]]
- # was blanked, it would take a long, long time to do incrementally.
- function incrementalSetup( $which, &$del, &$add )
- {
- if ( ! $this->mPreFilled ) {
- return false;
- }
-
- switch ( $which ) {
- case LINKCACHE_GOOD:
- $old =& $this->mOldGoodLinks;
- $cur =& $this->mGoodLinks;
- $del = $this->getGoodDeletions();
- $add = $this->getGoodAdditions();
- break;
- case LINKCACHE_BAD:
- $old =& $this->mOldBadLinks;
- $cur =& $this->mBadLinks;
- $del = $this->getBadDeletions();
- $add = $this->getBadAdditions();
- break;
- default: # LINKCACHE_IMAGE
- return false;
- }
-
- return true;
- }
-
- # Clears cache but leaves old preFill copies alone
- function clear()
- {
- $this->mGoodLinks = array();
- $this->mBadLinks = array();
- $this->mImageLinks = array();
- }
-
- /* private */ function fillFromLinkscc( $id ){
- $id = IntVal( $id );
- $res = wfQuery("SELECT lcc_cacheobj FROM linkscc WHERE lcc_pageid = $id",
- DB_READ);
- $row = wfFetchObject( $res );
- if( $row == FALSE)
- return false;
-
- $cacheobj = false;
- if( function_exists( "gzuncompress" ) )
- $cacheobj = @gzuncompress( $row->lcc_cacheobj );
-
- if($cacheobj == FALSE){
- $cacheobj = $row->lcc_cacheobj;
- }
- $cc = @unserialize( $cacheobj );
- if( isset( $cc->mClassVer ) and ($cc->mClassVer == $this->mClassVer ) ){
- $this->mOldGoodLinks = $this->mGoodLinks = $cc->mGoodLinks;
- $this->mOldBadLinks = $this->mBadLinks = $cc->mBadLinks;
- $this->mPreFilled = true;
- return TRUE;