From: Tim Starling Date: Mon, 23 Feb 2004 07:51:29 +0000 (+0000) Subject: Return of the Dumb Update (for rebuilding link tables) X-Git-Tag: 1.3.0beta1~961 X-Git-Url: http://git.cyclocoop.org/%27.parametre_url%28%20%20%20generer_action_auteur%28%27charger_plugin%27%2C%20%27update_flux%27%29%2C%27update_flux%27%2C%20%27oui%27%29.%27?a=commitdiff_plain;h=800cd47535a7431ccbb2131375a99d108672e812;p=lhc%2Fweb%2Fwiklou.git Return of the Dumb Update (for rebuilding link tables) --- diff --git a/includes/LinksUpdate.php b/includes/LinksUpdate.php index 81c449fe6e..fd17d44da5 100644 --- a/includes/LinksUpdate.php +++ b/includes/LinksUpdate.php @@ -141,7 +141,83 @@ class LinksUpdate { } wfProfileOut( $fname ); } + + function doDumbUpdate() + { + # Old inefficient update function + # Used for rebuilding the link table + + global $wgLinkCache, $wgDBtransactions; + $fname = "LinksUpdate::doDumbUpdate"; + wfProfileIn( $fname ); + + if( $wgDBtransactions ) { + $sql = "BEGIN"; + wfQuery( $sql, DB_WRITE, $fname ); + } + + $sql = "DELETE FROM links WHERE l_from='{$this->mTitleEnc}'"; + wfQuery( $sql, DB_WRITE, $fname ); + + $a = $wgLinkCache->getGoodLinks(); + $sql = ""; + if ( 0 != count( $a ) ) { + $sql = "INSERT INTO links (l_from,l_to) VALUES "; + $first = true; + foreach( $a as $lt => $lid ) { + if ( ! $first ) { $sql .= ","; } + $first = false; + + $sql .= "('{$this->mTitleEnc}',{$lid})"; + } + } + if ( "" != $sql ) { wfQuery( $sql, DB_WRITE, $fname ); } + + $sql = "DELETE FROM brokenlinks WHERE bl_from={$this->mId}"; + wfQuery( $sql, DB_WRITE, $fname ); + + $a = $wgLinkCache->getBadLinks(); + $sql = ""; + if ( 0 != count ( $a ) ) { + $sql = "INSERT INTO brokenlinks (bl_from,bl_to) VALUES "; + $first = true; + foreach( $a as $blt ) { + $blt = wfStrencode( $blt ); + if ( ! $first ) { $sql .= ","; } + $first = false; + + $sql .= "({$this->mId},'{$blt}')"; + } + } + if ( "" != $sql ) { wfQuery( $sql, DB_WRITE, $fname ); } + + $sql = "DELETE FROM imagelinks WHERE il_from='{$this->mTitleEnc}'"; + wfQuery( $sql, DB_WRITE, $fname ); + + $a = $wgLinkCache->getImageLinks(); + $sql = ""; + if ( 0 != count ( $a ) ) { + $sql = "INSERT INTO imagelinks (il_from,il_to) VALUES "; + $first = true; + foreach( $a as $iname => $val ) { + $iname = wfStrencode( $iname ); + if ( ! $first ) { $sql .= ","; } + $first = false; + + $sql .= "('{$this->mTitleEnc}','{$iname}')"; + } + } + if ( "" != $sql ) { wfQuery( $sql, DB_WRITE, $fname ); } + + $this->fixBrokenLinks(); + if( $wgDBtransactions ) { + $sql = "COMMIT"; + wfQuery( $sql, DB_WRITE, $fname ); + } + wfProfileOut( $fname ); + } + function fixBrokenLinks() { /* Update any brokenlinks *to* this page */ /* Call for a newly created page, or just to make sure state is consistent */