r1879 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r1878‎ | r1879 | r1880 >
Date:06:51, 4 November 2003
Author:vibber
Status:old
Tags:
Comment:
Revert last patchset
Modified paths:
  • /branches/stable/phase3/includes/Article.php (modified) (history)
  • /branches/stable/phase3/includes/LinkCache.php (modified) (history)
  • /branches/stable/phase3/includes/LinksUpdate.php (modified) (history)

Diff [purge]

Index: branches/stable/phase3/includes/Article.php
@@ -679,7 +679,7 @@
680680 wfStrencode( $summary ) . "',0,0," .
681681 ( $wgUser->isBot() ? 1 : 0 ) . ")";
682682 wfQuery( $sql, $fname );
683 - if ($watchthis) {
 683+ if ($watchthis) {
684684 if(!$wgTitle->userIsWatching()) $this->watch();
685685 } else {
686686 if ( $wgTitle->userIsWatching() ) {
@@ -1335,10 +1335,8 @@
13361336 $now = wfTimestampNow();
13371337 $sql2 = "UPDATE cur SET cur_touched='{$now}' WHERE cur_id IN (";
13381338 $first = true;
1339 -
1340 - global $wgLinkCache;
 1339+
13411340 while ( $s = wfFetchObject( $res ) ) {
1342 - $wgLinkCache->clearPreFill( $s->l_from );
13431341 $nt = Title::newFromDBkey( $s->l_from );
13441342 $lid = $nt->getArticleID();
13451343
@@ -1365,9 +1363,6 @@
13661364
13671365 $sql = "DELETE FROM brokenlinks WHERE bl_from={$id}";
13681366 wfQuery( $sql, $fname );
1369 -
1370 - global $wgLinkCache;
1371 - $wgLinkCache->clearPreFill( $t );
13721367 }
13731368
13741369 $log = new LogPage( wfMsg( "dellogpage" ), wfMsg( "dellogpagetext" ) );
Index: branches/stable/phase3/includes/LinkCache.php
@@ -12,16 +12,6 @@
1313 /* private */ var $mImageLinks;
1414 /* private */ var $mPreFilled, $mOldGoodLinks, $mOldBadLinks;
1515
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 -
2616 function LinkCache()
2717 {
2818 $this->mActive = true;
@@ -77,8 +67,6 @@
7868 if ( isset( $index ) ) {
7969 unset( $this->mBadLinks[$index] );
8070 }
81 - global $wgMemc;
82 - $wgMemc->delete( $this->getKey( $title ) );
8371 }
8472
8573 function suspend() { $this->mActive = false; }
@@ -104,54 +92,37 @@
10593 $id = $this->getGoodLinkID( $title );
10694 if ( 0 != $id ) { return $id; }
10795
108 - global $wgMemc;
109 - $fname = "LinkCache::addLinkObj";
110 - wfProfileIn( $fname );
 96+ wfProfileIn( "LinkCache::addLink-checkdatabase" );
11197
11298 $ns = $nt->getNamespace();
11399 $t = $nt->getDBkey();
114100
115 - if ( "" == $title ) {
116 - wfProfileOut( $fname );
117 - return 0;
 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;
118111 }
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 - }
134112 if ( 0 == $id ) { $this->addBadLink( $title ); }
135113 else { $this->addGoodLink( $id, $title ); }
136114 wfProfileOut();
137115 return $id;
138116 }
139117
140 - function preFill( &$fromtitle )
 118+ function preFill( $fromtitle )
141119 {
142 - $fname = "LinkCache::preFill";
143 - wfProfileIn( $fname );
 120+ wfProfileIn( "LinkCache::preFill" );
144121 # Note -- $fromtitle is a Title *object*
145122 $dbkeyfrom = wfStrencode( $fromtitle->getPrefixedDBKey() );
146 -
147 - if( $this->preFillFromCache( $dbkeyfrom ) ) {
148 - wfProfileOut();
149 - return;
150 - }
151 -
152123 $sql = "SELECT cur_id,cur_namespace,cur_title
153124 FROM cur,links
154125 WHERE cur_id=l_to AND l_from='{$dbkeyfrom}'";
155 - $res = wfQuery( $sql, $fname );
 126+ $res = wfQuery( $sql, "LinkCache::preFill" );
156127 while( $s = wfFetchObject( $res ) ) {
157128 $this->addGoodLink( $s->cur_id,
158129 Title::makeName( $s->cur_namespace, $s->cur_title )
@@ -164,8 +135,8 @@
165136
166137 $sql = "SELECT bl_to
167138 FROM brokenlinks
168 - WHERE bl_from={$id}";
169 - $res = wfQuery( $sql, $fname );
 139+ WHERE bl_from='{$id}'";
 140+ $res = wfQuery( $sql, "LinkCache::preFill" );
170141 while( $s = wfFetchObject( $res ) ) {
171142 $this->addBadLink( $s->bl_to );
172143 }
@@ -174,30 +145,8 @@
175146 $this->mOldGoodLinks = $this->mGoodLinks;
176147 $this->mPreFilled = true;
177148
178 - $this->preFillToCache( $dbkeyfrom );
179 -
180149 wfProfileOut();
181150 }
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 - }
202151
203152 function getGoodAdditions()
204153 {
Index: branches/stable/phase3/includes/LinksUpdate.php
@@ -141,8 +141,6 @@
142142 $sql = "COMMIT";
143143 wfQuery( $sql, $fname );
144144 }
145 -
146 - $wgLinkCache->clearPreFill( $this->mTitleEnc );
147145 wfProfileOut();
148146 }
149147
@@ -218,8 +216,6 @@
219217 $sql = "COMMIT";
220218 wfQuery( $sql, $fname );
221219 }
222 -
223 - $wgLinkCache->clearPreFill( $this->mTitleEnc );
224220 wfProfileOut();
225221 }
226222
@@ -227,11 +223,10 @@
228224 /* Update any brokenlinks *to* this page */
229225 /* Call for a newly created page, or just to make sure state is consistent */
230226
231 - $sql = "SELECT bl_from,cur_namespace,cur_title FROM brokenlinks,cur WHERE bl_to='{$this->mTitleEnc}' and bl_from=cur_id";
 227+ $sql = "SELECT bl_from FROM brokenlinks WHERE bl_to='{$this->mTitleEnc}'";
232228 $res = wfQuery( $sql, $fname );
233229 if ( 0 == wfNumRows( $res ) ) { return; }
234230
235 - global $wgLinkCache;
236231 $sql = "INSERT INTO links (l_from,l_to) VALUES ";
237232 $now = wfTimestampNow();
238233 $sql2 = "UPDATE cur SET cur_touched='{$now}' WHERE cur_id IN (";
@@ -243,8 +238,6 @@
244239
245240 $sql .= "('{$nl}',{$this->mId})";
246241 $sql2 .= $row->bl_from;
247 - $t = Title::makeTitle( $row->cur_namespace, $row->cur_title );
248 - $wgLinkCache->clearPreFill( $t->getPrefixedDBKey() );
249242 }
250243 $sql2 .= ")";
251244 wfQuery( $sql, $fname );

Status & tagging log