r62062 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r62061‎ | r62062 | r62063 >
Date:12:43, 6 February 2010
Author:ialex
Status:ok
Tags:
Comment:
* Don't throw a fatal error if the wiki ID passed to foreignUserLink() is invalid (but throw an exception instead)
* Make foreignLink() accept a WikiReference object so that it can be passed directly by foreignUserLink()
Modified paths:
  • /trunk/extensions/CentralAuth/SpecialCentralAuth.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CentralAuth/SpecialCentralAuth.php
@@ -430,9 +430,13 @@
431431 }
432432
433433 function foreignLink( $wikiID, $title, $text, $hint = '', $params = '' ) {
434 - $wiki = WikiMap::getWiki( $wikiID );
435 - if( !$wiki ) {
436 - throw new MWException( "Invalid wiki: $wikiID" );
 434+ if ( $wikiID instanceof WikiReference ) {
 435+ $wiki = $wikiID;
 436+ } else {
 437+ $wiki = WikiMap::getWiki( $wikiID );
 438+ if( !$wiki ) {
 439+ throw new MWException( "Invalid wiki: $wikiID" );
 440+ }
437441 }
438442
439443 $url = $wiki->getUrl( $title );
@@ -448,9 +452,13 @@
449453
450454 function foreignUserLink( $wikiID ) {
451455 $wiki = WikiMap::getWiki( $wikiID );
 456+ if( !$wiki ) {
 457+ throw new MWException( "Invalid wiki: $wikiID" );
 458+ }
 459+
452460 $wikiname = $wiki->getDisplayName();
453461 return $this->foreignLink(
454 - $wikiID,
 462+ $wiki,
455463 'User:' . $this->mUserName,
456464 $wikiname,
457465 wfMsg( 'centralauth-foreign-link', $this->mUserName, $wikiname ) );

Status & tagging log