Add wfFullUrl()/wfFullUrlE() function to explicitly include the http://foo.bar/ to...
[mediawiki.git] / includes / LinksUpdate.php
blobbf181ad6a5e437430de94c1c8416e4092385d210
1 <?
2 # See deferred.doc
4 class LinksUpdate {
6 /* private */ var $mId, $mTitle;
8 function LinksUpdate( $id, $title )
10 $this->mId = $id;
11 $this->mTitle = $title;
14 function doUpdate()
16 global $wgLinkCache, $wgDBtransactions;
17 $fname = "LinksUpdate::doUpdate";
18 wfProfileIn( $fname );
19 $t = wfStrencode( $this->mTitle );
21 if( $wgDBtransactions ) {
22 $sql = "BEGIN";
23 wfQuery( $sql, $fname );
26 $sql = "DELETE FROM links WHERE l_from='{$t}'";
27 wfQuery( $sql, $fname );
29 $a = $wgLinkCache->getGoodLinks();
30 $sql = "";
31 if ( 0 != count( $a ) ) {
32 $sql = "INSERT INTO links (l_from,l_to) VALUES ";
33 $first = true;
34 foreach( $a as $lt => $lid ) {
35 if ( ! $first ) { $sql .= ","; }
36 $first = false;
38 $sql .= "('{$t}',{$lid})";
41 if ( "" != $sql ) { wfQuery( $sql, $fname ); }
43 $sql = "DELETE FROM brokenlinks WHERE bl_from={$this->mId}";
44 wfQuery( $sql, $fname );
46 $a = $wgLinkCache->getBadLinks();
47 $sql = "";
48 if ( 0 != count ( $a ) ) {
49 $sql = "INSERT INTO brokenlinks (bl_from,bl_to) VALUES ";
50 $first = true;
51 foreach( $a as $blt ) {
52 $blt = wfStrencode( $blt );
53 if ( ! $first ) { $sql .= ","; }
54 $first = false;
56 $sql .= "({$this->mId},'{$blt}')";
59 if ( "" != $sql ) { wfQuery( $sql, $fname ); }
61 $sql = "DELETE FROM imagelinks WHERE il_from='{$t}'";
62 wfQuery( $sql, $fname );
64 $a = $wgLinkCache->getImageLinks();
65 $sql = "";
66 if ( 0 != count ( $a ) ) {
67 $sql = "INSERT INTO imagelinks (il_from,il_to) VALUES ";
68 $first = true;
69 foreach( $a as $iname => $val ) {
70 $iname = wfStrencode( $iname );
71 if ( ! $first ) { $sql .= ","; }
72 $first = false;
74 $sql .= "('{$t}','{$iname}')";
77 if ( "" != $sql ) { wfQuery( $sql, $fname ); }
79 $sql = "SELECT bl_from FROM brokenlinks WHERE bl_to='{$t}'";
80 $res = wfQuery( $sql, $fname );
81 if ( 0 == wfNumRows( $res ) ) { return; }
83 $sql = "INSERT INTO links (l_from,l_to) VALUES ";
84 $now = wfTimestampNow();
85 $sql2 = "UPDATE cur SET cur_touched='{$now}' WHERE cur_id IN (";
86 $first = true;
87 while ( $row = wfFetchObject( $res ) ) {
88 if ( ! $first ) { $sql .= ","; $sql2 .= ","; }
89 $first = false;
90 $nl = wfStrencode( Article::nameOf( $row->bl_from ) );
92 $sql .= "('{$nl}',{$this->mId})";
93 $sql2 .= $row->bl_from;
95 $sql2 .= ")";
96 wfQuery( $sql, $fname );
97 wfQuery( $sql2, $fname );
99 $sql = "DELETE FROM brokenlinks WHERE bl_to='{$t}'";
100 wfQuery( $sql, $fname );
102 if( $wgDBtransactions ) {
103 $sql = "COMMIT";
104 wfQuery( $sql, $fname );
106 wfProfileOut();