Index: trunk/phase3/includes/SpecialMovepage.php |
— | — | @@ -261,7 +261,7 @@ |
262 | 262 | |
263 | 263 | function moveOverExistingRedirect() |
264 | 264 | { |
265 | | - global $wgUser; |
| 265 | + global $wgUser, $wgLinkCache; |
266 | 266 | $fname = "MovePageForm::moveOverExistingRedirect"; |
267 | 267 | $mt = wfMsg( "movedto" ); |
268 | 268 | |
— | — | @@ -270,6 +270,7 @@ |
271 | 271 | "cur_namespace={$this->nns},cur_title='{$this->ndt}' " . |
272 | 272 | "WHERE cur_id={$this->oldid}"; |
273 | 273 | wfQuery( $sql, DB_WRITE, $fname ); |
| 274 | + $wgLinkCache->clearLink( $this->nft ); |
274 | 275 | |
275 | 276 | $sql = "UPDATE cur SET cur_touched='{$now}'," . |
276 | 277 | "cur_namespace={$this->ons},cur_title='{$this->odt}'," . |
— | — | @@ -279,6 +280,7 @@ |
280 | 281 | "cur_user_text='" . wfStrencode( $wgUser->getName() ) . "'," . |
281 | 282 | "cur_is_redirect=1,cur_is_new=0 WHERE cur_id={$this->newid}"; |
282 | 283 | wfQuery( $sql, DB_WRITE, $fname ); |
| 284 | + $wgLinkCache->clearLink( $this->oft ); |
283 | 285 | |
284 | 286 | $sql = "UPDATE old SET " . |
285 | 287 | "old_namespace={$this->nns},old_title='{$this->ndt}' WHERE " . |
— | — | @@ -332,7 +334,7 @@ |
333 | 335 | |
334 | 336 | function moveToNewTitle() |
335 | 337 | { |
336 | | - global $wgUser; |
| 338 | + global $wgUser, $wgLinkCache; |
337 | 339 | $fname = "MovePageForm::moveToNewTitle"; |
338 | 340 | $mt = wfMsg( "movedto" ); |
339 | 341 | |
— | — | @@ -342,6 +344,7 @@ |
343 | 345 | "cur_namespace={$this->nns},cur_title='{$this->ndt}' " . |
344 | 346 | "WHERE cur_id={$this->oldid}"; |
345 | 347 | wfQuery( $sql, DB_WRITE, $fname ); |
| 348 | + $wgLinkCache->clearLink( $this->nft ); |
346 | 349 | |
347 | 350 | $common = "{$this->ons},'{$this->odt}'," . |
348 | 351 | "'{$mt} \\\"{$this->nft}\\\"','" . |
— | — | @@ -353,6 +356,7 @@ |
354 | 357 | "VALUES ({$common},'{$won}','{$now}','#REDIRECT [[{$this->nft}]]\n',1,1)"; |
355 | 358 | wfQuery( $sql, DB_WRITE, $fname ); |
356 | 359 | $this->newid = wfInsertId(); |
| 360 | + $wgLinkCache->clearLink( $this->oft ); |
357 | 361 | |
358 | 362 | $sql = "UPDATE old SET " . |
359 | 363 | "old_namespace={$this->nns},old_title='{$this->ndt}' WHERE " . |
Index: trunk/phase3/includes/LinkCache.php |
— | — | @@ -12,6 +12,11 @@ |
13 | 13 | /* private */ var $mImageLinks; |
14 | 14 | /* private */ var $mPreFilled, $mOldGoodLinks, $mOldBadLinks; |
15 | 15 | |
| 16 | + /* private */ function getKey( $title ) { |
| 17 | + global $wgDBname; |
| 18 | + return "$wgDBname:lc:title:$title"; |
| 19 | + } |
| 20 | + |
16 | 21 | function LinkCache() |
17 | 22 | { |
18 | 23 | $this->mActive = true; |
— | — | @@ -56,15 +61,24 @@ |
57 | 62 | if ( $this->mActive ) { $this->mImageLinks[$title] = 1; } |
58 | 63 | } |
59 | 64 | |
| 65 | + function addImageLinkObj( $nt ) |
| 66 | + { |
| 67 | + if ( $this->mActive ) { $this->mImageLinks[$nt->getDBkey()] = 1; } |
| 68 | + } |
| 69 | + |
60 | 70 | function clearBadLink( $title ) |
61 | 71 | { |
62 | 72 | $index = array_search( $title, $this->mBadLinks ); |
63 | 73 | if ( isset( $index ) ) { |
64 | 74 | unset( $this->mBadLinks[$index] ); |
65 | 75 | } |
66 | | - global $wgMemc, $wgDBname; |
67 | | - $wgMemc->delete( "$wgDBname:lc:title:$title" ); |
| 76 | + $this->clearLink( $title ); |
68 | 77 | } |
| 78 | + |
| 79 | + function clearLink( $title ) { |
| 80 | + global $wgMemc; |
| 81 | + $wgMemc->delete( $this->getKey( $title ) ); |
| 82 | + } |
69 | 83 | |
70 | 84 | function suspend() { $this->mActive = false; } |
71 | 85 | function resume() { $this->mActive = true; } |
— | — | @@ -74,31 +88,37 @@ |
75 | 89 | |
76 | 90 | function addLink( $title ) |
77 | 91 | { |
78 | | - return $this->addLinkObj( Title::newFromDBkey( $title ) ); |
| 92 | + $nt = Title::newFromDBkey( $title ); |
| 93 | + if( $nt ) { |
| 94 | + return $this->addLinkObj( $nt ); |
| 95 | + } else { |
| 96 | + return 0; |
| 97 | + } |
79 | 98 | } |
80 | 99 | |
81 | 100 | function addLinkObj( &$nt ) |
82 | 101 | { |
83 | | - $title = $nt->getDBkey(); |
| 102 | + $title = $nt->getPrefixedDBkey(); |
84 | 103 | if ( $this->isBadLink( $title ) ) { return 0; } |
85 | 104 | $id = $this->getGoodLinkID( $title ); |
86 | 105 | if ( 0 != $id ) { return $id; } |
87 | 106 | |
88 | | - global $wgMemc, $wgDBname; |
89 | | - $fname = "LinkCache::addLink-checkdatabase"; |
| 107 | + global $wgMemc; |
| 108 | + $fname = "LinkCache::addLinkObj"; |
90 | 109 | wfProfileIn( $fname ); |
91 | 110 | |
92 | 111 | $ns = $nt->getNamespace(); |
| 112 | + $t = $nt->getDBkey(); |
93 | 113 | |
94 | 114 | if ( "" == $title ) { |
95 | 115 | wfProfileOut( $fname ); |
96 | 116 | return 0; |
97 | 117 | } |
98 | 118 | |
99 | | - $id = $wgMemc->get( $key = "$wgDBname:lc:title:$title" ); |
| 119 | + $id = $wgMemc->get( $key = $this->getKey( $title ) ); |
100 | 120 | if( $id === FALSE ) { |
101 | | - $sql = "SELECT HIGH_PRIORITY cur_id FROM cur WHERE cur_namespace=" . |
102 | | - "{$ns} AND cur_title='" . wfStrencode( $title ) . "'"; |
| 121 | + $sql = "SELECT cur_id FROM cur WHERE cur_namespace=" . |
| 122 | + "{$ns} AND cur_title='" . wfStrencode( $t ) . "'"; |
103 | 123 | $res = wfQuery( $sql, DB_READ, "LinkCache::addLink" ); |
104 | 124 | |
105 | 125 | if ( 0 == wfNumRows( $res ) ) { |
— | — | @@ -121,10 +141,10 @@ |
122 | 142 | wfProfileIn( $fname ); |
123 | 143 | # Note -- $fromtitle is a Title *object* |
124 | 144 | $dbkeyfrom = wfStrencode( $fromtitle->getPrefixedDBKey() ); |
125 | | - $sql = "SELECT HIGH_PRIORITY cur_id,cur_namespace,cur_title |
| 145 | + $sql = "SELECT cur_id,cur_namespace,cur_title |
126 | 146 | FROM cur,links |
127 | 147 | WHERE cur_id=l_to AND l_from='{$dbkeyfrom}'"; |
128 | | - $res = wfQuery( $sql, DB_READ, "LinkCache::preFill" ); |
| 148 | + $res = wfQuery( $sql, DB_READ, $fname ); |
129 | 149 | while( $s = wfFetchObject( $res ) ) { |
130 | 150 | $this->addGoodLink( $s->cur_id, |
131 | 151 | Title::makeName( $s->cur_namespace, $s->cur_title ) |
— | — | @@ -135,7 +155,7 @@ |
136 | 156 | $id = $fromtitle->getArticleID(); |
137 | 157 | $this->resume(); |
138 | 158 | |
139 | | - $sql = "SELECT HIGH_PRIORITY bl_to |
| 159 | + $sql = "SELECT bl_to |
140 | 160 | FROM brokenlinks |
141 | 161 | WHERE bl_from='{$id}'"; |
142 | 162 | $res = wfQuery( $sql, DB_READ, "LinkCache::preFill" ); |