Index: branches/stable/phase3/includes/SpecialMovepage.php |
— | — | @@ -338,7 +338,7 @@ |
339 | 339 | |
340 | 340 | function moveToNewTitle() |
341 | 341 | { |
342 | | - global $wgUser; |
| 342 | + global $wgUser, $wgLinkCache; |
343 | 343 | $fname = "MovePageForm::moveToNewTitle"; |
344 | 344 | $mt = wfMsg( "movedto" ); |
345 | 345 | |
— | — | @@ -348,6 +348,7 @@ |
349 | 349 | "cur_namespace={$this->nns},cur_title='{$this->ndt}' " . |
350 | 350 | "WHERE cur_id={$this->oldid}"; |
351 | 351 | wfQuery( $sql, $fname ); |
| 352 | + $wgLinkCache->clearLink( $this->oft ); |
352 | 353 | |
353 | 354 | $common = "{$this->ons},'{$this->odt}'," . |
354 | 355 | "'{$mt} \\\"{$this->nft}\\\"','" . |
— | — | @@ -359,6 +360,7 @@ |
360 | 361 | "VALUES ({$common},'{$won}','{$now}','#REDIRECT [[{$this->nft}]]\n',1,1)"; |
361 | 362 | wfQuery( $sql, $fname ); |
362 | 363 | $this->newid = wfInsertId(); |
| 364 | + $wgLinkCache->clearLink( $this->nft ); |
363 | 365 | |
364 | 366 | $sql = "UPDATE old SET " . |
365 | 367 | "old_namespace={$this->nns},old_title='{$this->ndt}' WHERE " . |
Index: branches/stable/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; |
— | — | @@ -67,7 +72,13 @@ |
68 | 73 | if ( isset( $index ) ) { |
69 | 74 | unset( $this->mBadLinks[$index] ); |
70 | 75 | } |
| 76 | + $this->clearLink( $title ); |
71 | 77 | } |
| 78 | + |
| 79 | + function clearLink( $title ) { |
| 80 | + global $wgMemc; |
| 81 | + $wgMemc->delete( $this->getKey( $title ) ); |
| 82 | + } |
72 | 83 | |
73 | 84 | function suspend() { $this->mActive = false; } |
74 | 85 | function resume() { $this->mActive = true; } |
— | — | @@ -92,22 +103,32 @@ |
93 | 104 | $id = $this->getGoodLinkID( $title ); |
94 | 105 | if ( 0 != $id ) { return $id; } |
95 | 106 | |
96 | | - wfProfileIn( "LinkCache::addLink-checkdatabase" ); |
| 107 | + global $wgMemc; |
| 108 | + $fname = "LinkCache::addLinkObj"; |
| 109 | + wfProfileIn( $fname ); |
97 | 110 | |
98 | 111 | $ns = $nt->getNamespace(); |
99 | 112 | $t = $nt->getDBkey(); |
100 | 113 | |
101 | | - if ( "" == $t ) { return 0; } |
102 | | - $sql = "SELECT cur_id FROM cur WHERE cur_namespace=" . |
103 | | - "{$ns} AND cur_title='" . wfStrencode( $t ) . "'"; |
104 | | - $res = wfQuery( $sql, "LinkCache::addLink" ); |
105 | | - |
106 | | - if ( 0 == wfNumRows( $res ) ) { |
107 | | - $id = 0; |
108 | | - } else { |
109 | | - $s = wfFetchObject( $res ); |
110 | | - $id = $s->cur_id; |
| 114 | + if ( "" == $title ) { |
| 115 | + wfProfileOut( $fname ); |
| 116 | + return 0; |
111 | 117 | } |
| 118 | + |
| 119 | + $id = $wgMemc->get( $key = $this->getKey( $title ) ); |
| 120 | + if( $id === FALSE ) { |
| 121 | + $sql = "SELECT cur_id FROM cur WHERE cur_namespace=" . |
| 122 | + "{$ns} AND cur_title='" . wfStrencode( $t ) . "'"; |
| 123 | + $res = wfQuery( $sql, $fname ); |
| 124 | + |
| 125 | + if ( 0 == wfNumRows( $res ) ) { |
| 126 | + $id = 0; |
| 127 | + } else { |
| 128 | + $s = wfFetchObject( $res ); |
| 129 | + $id = $s->cur_id; |
| 130 | + } |
| 131 | + $wgMemc->add( $key, $id, time() + 3600 ); |
| 132 | + } |
112 | 133 | if ( 0 == $id ) { $this->addBadLink( $title ); } |
113 | 134 | else { $this->addGoodLink( $id, $title ); } |
114 | 135 | wfProfileOut(); |
— | — | @@ -116,13 +137,14 @@ |
117 | 138 | |
118 | 139 | function preFill( $fromtitle ) |
119 | 140 | { |
120 | | - wfProfileIn( "LinkCache::preFill" ); |
| 141 | + $fname = "LinkCache::preFill"; |
| 142 | + wfProfileIn( $fname ); |
121 | 143 | # Note -- $fromtitle is a Title *object* |
122 | 144 | $dbkeyfrom = wfStrencode( $fromtitle->getPrefixedDBKey() ); |
123 | 145 | $sql = "SELECT cur_id,cur_namespace,cur_title |
124 | 146 | FROM cur,links |
125 | 147 | WHERE cur_id=l_to AND l_from='{$dbkeyfrom}'"; |
126 | | - $res = wfQuery( $sql, "LinkCache::preFill" ); |
| 148 | + $res = wfQuery( $sql, $fname ); |
127 | 149 | while( $s = wfFetchObject( $res ) ) { |
128 | 150 | $this->addGoodLink( $s->cur_id, |
129 | 151 | Title::makeName( $s->cur_namespace, $s->cur_title ) |