r99447 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r99446‎ | r99447 | r99448 >
Date:23:40, 10 October 2011
Author:reedy
Status:ok
Tags:
Comment:
Documentation

Swap an if to be an elseif
Modified paths:
  • /trunk/extensions/Interlanguage/Interlanguage.php (modified) (history)
  • /trunk/extensions/Interlanguage/InterlanguageCentral.php (modified) (history)
  • /trunk/extensions/Interlanguage/InterlanguageExtension.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Interlanguage/InterlanguageCentral.php
@@ -39,6 +39,10 @@
4040 $wgAutoloadClasses['InterlanguageCentralExtension'] = dirname(__FILE__) . '/InterlanguageCentralExtension.php';
4141 $wgHooks['ParserFirstCallInit'][] = 'wfInterlanguageCentralExtension';
4242
 43+/**
 44+ * @param $parser Parser
 45+ * @return bool
 46+ */
4347 function wfInterlanguageCentralExtension( $parser ) {
4448 global $wgHooks, $wgInterlanguageCentralExtension;
4549
Index: trunk/extensions/Interlanguage/InterlanguageExtension.php
@@ -25,8 +25,17 @@
2626 */
2727
2828 class InterlanguageExtension {
 29+
 30+ /**
 31+ * @var DatabaseBase
 32+ */
2933 var $foreignDbr = false;
3034
 35+ /**
 36+ * @param $magicWords array
 37+ * @param $langCode string
 38+ * @return bool
 39+ */
3140 function onLanguageGetMagic( &$magicWords, $langCode ) {
3241 $magicWords['interlanguage'] = array(0, 'interlanguage');
3342 return true;
@@ -35,12 +44,10 @@
3645 /**
3746 * The meat of the extension, the function that handles {{interlanguage:}} magic.
3847 *
39 - * @param $parser - standard Parser object.
40 - * @param $param - parameter passed to {{interlanguage:}}.
 48+ * @param $parser Parser standard Parser object.
 49+ * @param $param parameter passed to {{interlanguage:}}.
4150 */
4251 function interlanguage( &$parser, $param ) {
43 - global $wgMemc;
44 -
4552 $this->addPageLink( $parser->getOutput(), $param );
4653 $parser->getOutput()->addModules( 'ext.Interlanguage' );
4754
@@ -49,9 +56,7 @@
5057
5158 if($res === false) {
5259 list( $res, $a ) = $this->preservePageLinks( $parser->mTitle->mArticleID );
53 - }
54 -
55 - if($res === true) {
 60+ } elseif ($res === true) {
5661 $this->sortLinks( $a );
5762 $res = $this->linksToWiki( $a );
5863 }
@@ -173,6 +178,9 @@
174179
175180 /**
176181 * Add a page to the list of page links. It will later be used by pageLinks().
 182+ *
 183+ * @param $parserOutput ParserOutput
 184+ * @param $param
177185 */
178186 function addPageLink( &$parserOutput, $param ) {
179187 $ilp = $parserOutput->getProperty( 'interlanguage_pages' );
@@ -186,7 +194,7 @@
187195 /**
188196 * Get the list of page links.
189197 *
190 - * @param $parserOutput
 198+ * @param $parserOutput ParserOutput
191199 * @return Array of page links. Empty array if there are no links, literal false if links have not
192200 * been yet set.
193201 */
@@ -303,8 +311,8 @@
304312 /**
305313 * Make an array of Titles from the array of links.
306314 *
307 - * @param $pagelinks Array of page links.
308 - * @returns Array of Title objects. If there are no page links, an empty array is returned.
 315+ * @param $pagelinks Array of page links.
 316+ * @return Array of Title objects. If there are no page links, an empty array is returned.
309317 */
310318 function makePageLinkTitles( $pagelinks ) {
311319 global $wgInterlanguageExtensionInterwiki;
@@ -328,7 +336,7 @@
329337 * on this wiki by {{interlanguage:}} magic. Pagenames are array keys.
330338 *
331339 * @param $articleid - ID of the article whose links should be returned.
332 - * @returns The array. If there are no pages linked, an empty array is returned.
 340+ * @return The array. If there are no pages linked, an empty array is returned.
333341 */
334342 function loadPageLinks( $articleid ) {
335343 $dbr = wfGetDB( DB_SLAVE );
@@ -356,9 +364,9 @@
357365 * Read interlanguage links from a database, and return them in the same format that API
358366 * uses.
359367 *
360 - * @param $dbr - Database.
361 - * @param $articleid - ID of the article whose links should be returned.
362 - * @returns The array with the links. If there are no links, an empty array is returned.
 368+ * @param $dbr DatabaseBase
 369+ * @param $articleid int ID of the article whose links should be returned.
 370+ * @return The array with the links. If there are no links, an empty array is returned.
363371 */
364372 function readLinksFromDB( $dbr, $articleid ) {
365373 $res = $dbr->select(
@@ -371,7 +379,6 @@
372380 foreach( $res as $row ) {
373381 $a[] = array( 'lang' => $row->ll_lang, '*' => $row->ll_title );
374382 }
375 - $res->free();
376383 return $a;
377384 }
378385
Index: trunk/extensions/Interlanguage/Interlanguage.php
@@ -47,6 +47,10 @@
4848 'remoteExtPath' => 'Interlanguage',
4949 );
5050
 51+/**
 52+ * @param $parser Parser
 53+ * @return bool
 54+ */
5155 function wfInterlanguageExtension( $parser ) {
5256 global $wgHooks, $wgInterlanguageExtension;
5357

Status & tagging log