r69783 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r69782‎ | r69783 | r69784 >
Date:10:24, 23 July 2010
Author:peter17
Status:ok
Tags:
Comment:
Correct style and solve a bug that appears when caching is enabled
Modified paths:
  • /branches/iwtransclusion/phase3/includes/Interwiki.php (modified) (history)
  • /branches/iwtransclusion/phase3/includes/Revision.php (modified) (history)

Diff [purge]

Index: branches/iwtransclusion/phase3/includes/Interwiki.php
@@ -155,7 +155,11 @@
156156 __METHOD__ ) );
157157 $iw = Interwiki::loadFromArray( $row );
158158 if ( $iw ) {
159 - $mc = array( 'iw_url' => $iw->mURL, 'iw_api' => $iw->mAPI, 'iw_local' => $iw->mLocal, 'iw_trans' => $iw->mTrans );
 159+ $mc = array( 'iw_url' => $iw->mURL,
 160+ 'iw_api' => $iw->mAPI,
 161+ 'iw_wikiid' => $iw->mWikiID,
 162+ 'iw_local' => $iw->mLocal,
 163+ 'iw_trans' => $iw->mTrans );
160164 $wgMemc->add( $key, $mc, $wgInterwikiExpiry );
161165 return $iw;
162166 }
@@ -257,7 +261,6 @@
258262 return wfEmptyMsg( $key, $msg ) ? '' : $msg;
259263 }
260264
261 -
262265
263266 /**
264267 * Transclude an interwiki link.
@@ -337,13 +340,13 @@
338341
339342 $key = wfMemcKey( 'iwtransclustiontext', 'textid', $wikiID, $fullTitle );
340343 $text = $wgMemc->get( $key );
341 - if( is_array ( $text )
342 - && isset ( $text['missing'] )
343 - && $text['missing'] === true ){
344 - return false;
345 - } else if ( $text ) {
346 - return $text;
347 - }
 344+ if( is_array ( $text ) &&
 345+ isset ( $text['missing'] ) &&
 346+ $text['missing'] === true ) {
 347+ return false;
 348+ } else if ( $text ) {
 349+ return $text;
 350+ }
348351
349352 $url = wfAppendQuery(
350353 $transAPI,
@@ -358,17 +361,16 @@
359362 $get = Http::get( $url );
360363 $content = FormatJson::decode( $get, true );
361364
362 - if ( isset ( $content['query'] )
363 - && isset ( $content['query']['pages'] ) ) {
364 - $page = array_pop( $content['query']['pages'] );
365 - if ( $page
366 - && isset( $page['revisions'][0]['*'] ) ) {
367 - $text = $page['revisions'][0]['*'];
368 - $wgMemc->set( $key, $text, $wgTranscludeCacheExpiry );
369 - return $text;
370 - } else {
371 - $wgMemc->set( $key, array ( 'missing' => true ), $wgTranscludeCacheExpiry );
372 - }
 365+ if ( isset ( $content['query'] ) &&
 366+ isset ( $content['query']['pages'] ) ) {
 367+ $page = array_pop( $content['query']['pages'] );
 368+ if ( $page && isset( $page['revisions'][0]['*'] ) ) {
 369+ $text = $page['revisions'][0]['*'];
 370+ $wgMemc->set( $key, $text, $wgTranscludeCacheExpiry );
 371+ return $text;
 372+ } else {
 373+ $wgMemc->set( $key, array ( 'missing' => true ), $wgTranscludeCacheExpiry );
 374+ }
373375 }
374376 return false;
375377 }
@@ -403,8 +405,8 @@
404406 $get = Http::get( $url );
405407 $content = FormatJson::decode( $get, true );
406408
407 - if ( isset ( $content['query'] )
408 - && isset ( $content['query']['pages'] ) ) {
 409+ if ( isset ( $content['query'] ) &&
 410+ isset ( $content['query']['pages'] ) ) {
409411 foreach( $content['query']['pages'] as $page ) {
410412 $key = wfMemcKey( 'iwtransclustiontext', 'textid', $wikiID, $page['title'] );
411413 if ( isset ( $page['revisions'][0]['*'] ) ) {
@@ -414,7 +416,7 @@
415417 }
416418 $wgMemc->set( $key, $text, $wgTranscludeCacheExpiry );
417419 }
418 - }
 420+ }
419421 }
420422 }
421423 }
Index: branches/iwtransclusion/phase3/includes/Revision.php
@@ -906,7 +906,7 @@
907907 global $wgRevisionCacheExpiry, $wgMemc;
908908 $textId = $this->getTextId();
909909 if( isset( $this->mWikiID ) ) {
910 - $key = wfForeignMemcKey( $this->mWikiID, 'revisiontext', 'textid', $textId );
 910+ $key = wfForeignMemcKey( $this->mWikiID, null, 'revisiontext', 'textid', $textId );
911911 } else {
912912 $key = wfMemcKey( 'revisiontext', 'textid', $textId );
913913 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r87106Merge r69745, r69746, r69781, r69783reedy00:28, 29 April 2011
r92987Merge r87106 which is a Merge r69745, r69746, r69781, r69783reedy17:25, 24 July 2011

Status & tagging log