Index: branches/stable/phase3/includes/Article.php |
— | — | @@ -679,7 +679,7 @@ |
680 | 680 | wfStrencode( $summary ) . "',0,0," . |
681 | 681 | ( $wgUser->isBot() ? 1 : 0 ) . ")"; |
682 | 682 | wfQuery( $sql, $fname ); |
683 | | - if ($watchthis) { |
| 683 | + if ($watchthis) { |
684 | 684 | if(!$wgTitle->userIsWatching()) $this->watch(); |
685 | 685 | } else { |
686 | 686 | if ( $wgTitle->userIsWatching() ) { |
— | — | @@ -1335,8 +1335,10 @@ |
1336 | 1336 | $now = wfTimestampNow(); |
1337 | 1337 | $sql2 = "UPDATE cur SET cur_touched='{$now}' WHERE cur_id IN ("; |
1338 | 1338 | $first = true; |
1339 | | - |
| 1339 | + |
| 1340 | + global $wgLinkCache; |
1340 | 1341 | while ( $s = wfFetchObject( $res ) ) { |
| 1342 | + $wgLinkCache->clearPreFill( $s->l_from ); |
1341 | 1343 | $nt = Title::newFromDBkey( $s->l_from ); |
1342 | 1344 | $lid = $nt->getArticleID(); |
1343 | 1345 | |
— | — | @@ -1363,6 +1365,9 @@ |
1364 | 1366 | |
1365 | 1367 | $sql = "DELETE FROM brokenlinks WHERE bl_from={$id}"; |
1366 | 1368 | wfQuery( $sql, $fname ); |
| 1369 | + |
| 1370 | + global $wgLinkCache; |
| 1371 | + $wgLinkCache->clearPreFill( $t ); |
1367 | 1372 | } |
1368 | 1373 | |
1369 | 1374 | $log = new LogPage( wfMsg( "dellogpage" ), wfMsg( "dellogpagetext" ) ); |
Index: branches/stable/phase3/includes/DefaultSettings.php |
— | — | @@ -37,6 +37,13 @@ |
38 | 38 | $wgDBtransactions = false; # Set to true if using InnoDB tables |
39 | 39 | $wgDBmysql4 = false; # Set to true to use enhanced fulltext search |
40 | 40 | |
| 41 | +# memcached settings |
| 42 | +# See docs/memcached.doc |
| 43 | +# |
| 44 | +$wgUseMemCached = false; |
| 45 | +$wgMemCachedServers = array( "127.0.0.1:11000" ); |
| 46 | +$wgMemCachedDebug = false; |
| 47 | + |
41 | 48 | # Language settings |
42 | 49 | # |
43 | 50 | $wgLanguageCode = "en"; |
Index: branches/stable/phase3/includes/LinkCache.php |
— | — | @@ -12,6 +12,16 @@ |
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 | + |
| 21 | + /* private */ function getPrefillKey( $title ) { |
| 22 | + global $wgDBname; |
| 23 | + return "$wgDBname:lc:prefill:$title"; |
| 24 | + } |
| 25 | + |
16 | 26 | function LinkCache() |
17 | 27 | { |
18 | 28 | $this->mActive = true; |
— | — | @@ -67,6 +77,8 @@ |
68 | 78 | if ( isset( $index ) ) { |
69 | 79 | unset( $this->mBadLinks[$index] ); |
70 | 80 | } |
| 81 | + global $wgMemc; |
| 82 | + $wgMemc->delete( $this->getKey( $title ) ); |
71 | 83 | } |
72 | 84 | |
73 | 85 | function suspend() { $this->mActive = false; } |
— | — | @@ -92,37 +104,54 @@ |
93 | 105 | $id = $this->getGoodLinkID( $title ); |
94 | 106 | if ( 0 != $id ) { return $id; } |
95 | 107 | |
96 | | - wfProfileIn( "LinkCache::addLink-checkdatabase" ); |
| 108 | + global $wgMemc; |
| 109 | + $fname = "LinkCache::addLinkObj"; |
| 110 | + wfProfileIn( $fname ); |
97 | 111 | |
98 | 112 | $ns = $nt->getNamespace(); |
99 | 113 | $t = $nt->getDBkey(); |
100 | 114 | |
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; |
| 115 | + if ( "" == $title ) { |
| 116 | + wfProfileOut( $fname ); |
| 117 | + return 0; |
111 | 118 | } |
| 119 | + |
| 120 | + $id = $wgMemc->get( $key = $this->getKey( $title ) ); |
| 121 | + if( $id === FALSE ) { |
| 122 | + $sql = "SELECT cur_id FROM cur WHERE cur_namespace=" . |
| 123 | + "{$ns} AND cur_title='" . wfStrencode( $t ) . "'"; |
| 124 | + $res = wfQuery( $sql, $fname ); |
| 125 | + |
| 126 | + if ( 0 == wfNumRows( $res ) ) { |
| 127 | + $id = 0; |
| 128 | + } else { |
| 129 | + $s = wfFetchObject( $res ); |
| 130 | + $id = $s->cur_id; |
| 131 | + } |
| 132 | + $wgMemc->add( $key, $id, time() + 3600 ); |
| 133 | + } |
112 | 134 | if ( 0 == $id ) { $this->addBadLink( $title ); } |
113 | 135 | else { $this->addGoodLink( $id, $title ); } |
114 | 136 | wfProfileOut(); |
115 | 137 | return $id; |
116 | 138 | } |
117 | 139 | |
118 | | - function preFill( $fromtitle ) |
| 140 | + function preFill( &$fromtitle ) |
119 | 141 | { |
120 | | - wfProfileIn( "LinkCache::preFill" ); |
| 142 | + $fname = "LinkCache::preFill"; |
| 143 | + wfProfileIn( $fname ); |
121 | 144 | # Note -- $fromtitle is a Title *object* |
122 | 145 | $dbkeyfrom = wfStrencode( $fromtitle->getPrefixedDBKey() ); |
| 146 | + |
| 147 | + if( $this->preFillFromCache( $dbkeyfrom ) ) { |
| 148 | + wfProfileOut(); |
| 149 | + return; |
| 150 | + } |
| 151 | + |
123 | 152 | $sql = "SELECT cur_id,cur_namespace,cur_title |
124 | 153 | FROM cur,links |
125 | 154 | WHERE cur_id=l_to AND l_from='{$dbkeyfrom}'"; |
126 | | - $res = wfQuery( $sql, "LinkCache::preFill" ); |
| 155 | + $res = wfQuery( $sql, $fname ); |
127 | 156 | while( $s = wfFetchObject( $res ) ) { |
128 | 157 | $this->addGoodLink( $s->cur_id, |
129 | 158 | Title::makeName( $s->cur_namespace, $s->cur_title ) |
— | — | @@ -135,8 +164,8 @@ |
136 | 165 | |
137 | 166 | $sql = "SELECT bl_to |
138 | 167 | FROM brokenlinks |
139 | | - WHERE bl_from='{$id}'"; |
140 | | - $res = wfQuery( $sql, "LinkCache::preFill" ); |
| 168 | + WHERE bl_from={$id}"; |
| 169 | + $res = wfQuery( $sql, $fname ); |
141 | 170 | while( $s = wfFetchObject( $res ) ) { |
142 | 171 | $this->addBadLink( $s->bl_to ); |
143 | 172 | } |
— | — | @@ -145,8 +174,30 @@ |
146 | 175 | $this->mOldGoodLinks = $this->mGoodLinks; |
147 | 176 | $this->mPreFilled = true; |
148 | 177 | |
| 178 | + $this->preFillToCache( $dbkeyfrom ); |
| 179 | + |
149 | 180 | wfProfileOut(); |
150 | 181 | } |
| 182 | + |
| 183 | + function preFillFromCache( $dbkey ) { |
| 184 | + global $wgMemc; |
| 185 | + $prefill = $wgMemc->get( $this->getPrefillKey( $dbkey ) ); |
| 186 | + if( $prefill === FALSE ) return false; |
| 187 | + list( $this->mGoodLinks, $this->mBadLinks, $this->mImageLinks ) = $prefill; |
| 188 | + list( $this->mOldGoodLinks, $this->mOldBadLinks ) = $prefill; |
| 189 | + return $this->mPreFilled = true; |
| 190 | + } |
| 191 | + |
| 192 | + function preFillToCache( $dbkey ) { |
| 193 | + global $wgMemc; |
| 194 | + $prefill = array( $this->mGoodLinks, $this->mBadLinks, $this->mImageLinks ); |
| 195 | + $wgMemc->set( $this->getPrefillKey( $dbkey ), $prefill, time() + 3600 ); |
| 196 | + } |
| 197 | + |
| 198 | + function clearPreFill( $dbkey ) { |
| 199 | + global $wgMemc; |
| 200 | + $wgMemc->delete( $this->getPrefillKey( $dbkey ) ); |
| 201 | + } |
151 | 202 | |
152 | 203 | function getGoodAdditions() |
153 | 204 | { |
Index: branches/stable/phase3/includes/LinksUpdate.php |
— | — | @@ -141,6 +141,8 @@ |
142 | 142 | $sql = "COMMIT"; |
143 | 143 | wfQuery( $sql, $fname ); |
144 | 144 | } |
| 145 | + |
| 146 | + $wgLinkCache->clearPreFill( $this->mTitleEnc ); |
145 | 147 | wfProfileOut(); |
146 | 148 | } |
147 | 149 | |
— | — | @@ -216,6 +218,8 @@ |
217 | 219 | $sql = "COMMIT"; |
218 | 220 | wfQuery( $sql, $fname ); |
219 | 221 | } |
| 222 | + |
| 223 | + $wgLinkCache->clearPreFill( $this->mTitleEnc ); |
220 | 224 | wfProfileOut(); |
221 | 225 | } |
222 | 226 | |
— | — | @@ -223,10 +227,11 @@ |
224 | 228 | /* Update any brokenlinks *to* this page */ |
225 | 229 | /* Call for a newly created page, or just to make sure state is consistent */ |
226 | 230 | |
227 | | - $sql = "SELECT bl_from FROM brokenlinks WHERE bl_to='{$this->mTitleEnc}'"; |
| 231 | + $sql = "SELECT bl_from,cur_namespace,cur_title FROM brokenlinks,cur WHERE bl_to='{$this->mTitleEnc}' and bl_from=cur_id"; |
228 | 232 | $res = wfQuery( $sql, $fname ); |
229 | 233 | if ( 0 == wfNumRows( $res ) ) { return; } |
230 | 234 | |
| 235 | + global $wgLinkCache; |
231 | 236 | $sql = "INSERT INTO links (l_from,l_to) VALUES "; |
232 | 237 | $now = wfTimestampNow(); |
233 | 238 | $sql2 = "UPDATE cur SET cur_touched='{$now}' WHERE cur_id IN ("; |
— | — | @@ -238,6 +243,8 @@ |
239 | 244 | |
240 | 245 | $sql .= "('{$nl}',{$this->mId})"; |
241 | 246 | $sql2 .= $row->bl_from; |
| 247 | + $t = Title::makeTitle( $row->cur_namespace, $row->cur_title ); |
| 248 | + $wgLinkCache->clearPreFill( $t->getPrefixedDBKey() ); |
242 | 249 | } |
243 | 250 | $sql2 .= ")"; |
244 | 251 | wfQuery( $sql, $fname ); |