r73951 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r73950‎ | r73951 | r73952 >
Date:15:54, 29 September 2010
Author:platonides
Status:ok (Comments)
Tags:
Comment:
Tiny changes, fix comment, remove unused globals and throw and exception instead of a fatal if given a wrong langcode.
Modified paths:
  • /trunk/phase3/includes/Article.php (modified) (history)
  • /trunk/phase3/includes/MessageCache.php (modified) (history)
  • /trunk/phase3/includes/ResourceLoader.php (modified) (history)
  • /trunk/phase3/maintenance/tests/phpunit/includes/api/ApiSetup.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/tests/phpunit/includes/api/ApiSetup.php
@@ -7,8 +7,7 @@
88 protected static $apiUrl;
99
1010 function setUp() {
11 - global $wgServer, $wgContLang, $wgAuth, $wgScriptPath,
12 - $wgScriptExtension, $wgMemc, $wgRequest;
 11+ global $wgServer, $wgContLang, $wgAuth, $wgMemc, $wgRequest;
1312
1413 self::$apiUrl = $wgServer . wfScript( 'api' );
1514
Index: trunk/phase3/includes/Article.php
@@ -853,7 +853,7 @@
854854 $wgOut->setETag( $parserCache->getETag( $this, $parserOptions ) );
855855 }
856856
857 - # Is is client cached?
 857+ # Is it client cached?
858858 if ( $wgOut->checkLastModified( $this->getTouched() ) ) {
859859 wfDebug( __METHOD__ . ": done 304\n" );
860860 wfProfileOut( __METHOD__ );
Index: trunk/phase3/includes/MessageCache.php
@@ -546,6 +546,8 @@
547547 }
548548
549549 $lang = wfGetLangObj( $langcode );
 550+ if (!$lang) throw new MWException( "Bad lang code $langcode given" );
 551+
550552 $langcode = $lang->getCode();
551553
552554 $message = false;
Index: trunk/phase3/includes/ResourceLoader.php
@@ -327,8 +327,6 @@
328328 }
329329
330330 public static function makeModuleResponse( ResourceLoaderContext $context, array $modules, $missing = null ) {
331 - global $wgUser;
332 -
333331 // Pre-fetch blobs
334332 $blobs = $context->shouldIncludeMessages() ?
335333 MessageBlobStore::get( array_keys( $modules ), $context->getLanguage() ) : array();

Follow-up revisions

RevisionCommit summaryAuthorDate
r73981Follow up r73951platonides20:24, 29 September 2010

Comments

#Comment by Nikerabbit (talk | contribs)   15:59, 29 September 2010
+if (!$lang) throw new MWException( "Bad lang code $langcode given" );

As far as I can see wfGetLangObj() can't return false or null.

#Comment by Platonides (talk | contribs)   16:12, 29 September 2010

It shouldn't reach there, but I found that case with some unit tests and its run order. Throwing an exception makes it easier to debug should it happen again.

> $wgLang = false;

> var_dump( wfGetLangObj() );

bool(false)

#Comment by Nikerabbit (talk | contribs)   16:18, 29 September 2010

Interesting. Well, then it should have spaces around parentheses at least :)

#Comment by Platonides (talk | contribs)   20:24, 29 September 2010

Done in r73981.

Status & tagging log