r104993 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r104992‎ | r104993 | r104994 >
Date:19:41, 2 December 2011
Author:reedy
Status:ok
Tags:
Comment:
Documentation

Explicitly defined some variables before loops

Left 1 fixme of use of undefined variables

Tidy up some returns
Modified paths:
  • /trunk/extensions/WikimediaIncubator/CreateAccountTestWiki.php (modified) (history)
  • /trunk/extensions/WikimediaIncubator/IncubatorTest.php (modified) (history)
  • /trunk/extensions/WikimediaIncubator/InfoPage.php (modified) (history)
  • /trunk/extensions/WikimediaIncubator/ListUsersTestWiki.php (modified) (history)
  • /trunk/extensions/WikimediaIncubator/SpecialViewUserLang.php (modified) (history)

Diff [purge]

Index: trunk/extensions/WikimediaIncubator/SpecialViewUserLang.php
@@ -16,6 +16,9 @@
1717 parent::__construct( 'ViewUserLang', 'viewuserlang' );
1818 }
1919
 20+ /**
 21+ * @return String
 22+ */
2023 function getDescription() { return wfMsg( 'wminc-viewuserlang' ); }
2124
2225 /**
@@ -70,7 +73,8 @@
7174 global $wgOut, $wmincPref, $wmincProjectSite;
7275 if( User::isIP( $target ) ) {
7376 # show error if it is an IP address
74 - return $wgOut->addHTML( Xml::span( wfMsg( 'wminc-ip', $target ), 'error' ) );
 77+ $wgOut->addHTML( Xml::span( wfMsg( 'wminc-ip', $target ), 'error' ) );
 78+ return;
7579 }
7680 $user = User::newFromName( $target );
7781 $name = $user->getName();
@@ -79,7 +83,8 @@
8084 $linker = class_exists( 'DummyLinker' ) ? new DummyLinker : new Linker;
8185 if ( $user == null || $id == 0 ) {
8286 # show error if a user with that name does not exist
83 - return $wgOut->addHTML( Xml::span( wfMsg( 'wminc-userdoesnotexist', $target ), 'error' ) );
 87+ $wgOut->addHTML( Xml::span( wfMsg( 'wminc-userdoesnotexist', $target ), 'error' ) );
 88+ return;
8489 }
8590 $userproject = $user->getOption( $wmincPref . '-project' );
8691 $userproject = ( $userproject ? $userproject : 'none' );
Index: trunk/extensions/WikimediaIncubator/ListUsersTestWiki.php
@@ -14,7 +14,7 @@
1515 if( $input == strtolower( $wmincProjectSite['name'] ) || $input == strtolower( $wmincProjectSite['short'] ) ) {
1616 return $wmincProjectSite;
1717 }
18 - return;
 18+ return null;
1919 }
2020
2121 /**
@@ -31,13 +31,20 @@
3232
3333 /**
3434 * Show a message that you are viewing a list of users of a certain test wiki
 35+ * @param $pager
 36+ * @param $out
 37+ * @return bool
3538 */
3639 static function onSpecialListusersHeader( $pager, &$out ) {
37 - if( $project = self::getProjectInput() ) {
 40+ $project = self::getProjectInput();
 41+ if( $project ) {
3842 $out .= wfMsgWikiHtml( 'wminc-listusers-testwiki', '"' . $project['name'] . '"' );
39 - } elseif( $testwiki = IncubatorTest::getUrlParam() ) {
40 - $link = Linker::linkKnown( Title::newFromText( $testwiki['prefix'] ) );
41 - $out .= wfMsgWikiHtml( 'wminc-listusers-testwiki', $link );
 43+ } else {
 44+ $testwiki = IncubatorTest::getUrlParam();
 45+ if ( $testwiki ) {
 46+ $link = Linker::linkKnown( Title::newFromText( $testwiki['prefix'] ) );
 47+ $out .= wfMsgWikiHtml( 'wminc-listusers-testwiki', $link );
 48+ }
4249 }
4350 return true;
4451 }
Index: trunk/extensions/WikimediaIncubator/CreateAccountTestWiki.php
@@ -12,6 +12,11 @@
1313 */
1414
1515 class AutoTestWiki {
 16+
 17+ /**
 18+ * @param $template UsercreateTemplate|UserloginTemplate
 19+ * @return bool
 20+ */
1621 public static function onUserCreateForm( $template ) {
1722 global $wgRequest, $wmincProjects;
1823 $projectvalue = strtolower( $wgRequest->getVal( 'testwikiproject', '' ) );
@@ -25,6 +30,10 @@
2631 return true;
2732 }
2833
 34+ /**
 35+ * @param $user User
 36+ * @return bool
 37+ */
2938 public static function onAddNewAccount( $user ) {
3039 global $wgRequest, $wmincProjects, $wmincPref;
3140 $projectvalue = $wgRequest->getVal( 'testwiki-project' );
Index: trunk/extensions/WikimediaIncubator/IncubatorTest.php
@@ -13,7 +13,9 @@
1414
1515 /**
1616 * Add preferences
17 - * @return True
 17+ * @param $user User
 18+ * @param $preferences array
 19+ * @return true
1820 */
1921 static function onGetPreferences( $user, &$preferences ) {
2022 global $wmincPref, $wmincProjects, $wmincProjectSite,
@@ -52,6 +54,8 @@
5355
5456 /**
5557 * For the preferences above
 58+ * @param $input
 59+ * @param $alldata
5660 * @return String or true
5761 */
5862 static function validateCodePreference( $input, $alldata ) {
@@ -135,15 +139,15 @@
136140
137141 /**
138142 * This returns simply true or false based on analyzePrefix().
 143+ * @param $title Title
 144+ * @param $onlyprefix bool
139145 * @return Boolean
140146 */
141147 static function validatePrefix( $title, $onlyprefix = false ) {
142148 $data = self::analyzePrefix( $title, $onlyprefix );
143 - if( !$data['error'] ) { return true; }
144 - return false;
 149+ return !$data['error'];
145150 }
146151
147 -
148152 /**
149153 * Get &testwiki=wx/xx and validate that prefix.
150154 * Returns the array of analyzePrefix() on success.
@@ -197,6 +201,10 @@
198202
199203 /**
200204 * Returns a simple boolean based on getProject()
 205+ * @param $project string
 206+ * @param $returnName bool
 207+ * @param $returnName bool
 208+ * @param $includeSister bool
201209 * @return Bool
202210 */
203211 static function isContentProject( $project = '', $returnName = false, $includeSister = false ) {
@@ -400,7 +408,7 @@
401409 }
402410 return true; # Should work now
403411 }
404 -
 412+
405413 /**
406414 * Given an incubator testwiki prefix, get the database name of the
407415 * corresponding wiki, whether it exists or not
@@ -527,7 +535,7 @@
528536 $wgOut->addHtml( $infopage->showExistingWiki() );
529537 } elseif( $dbstate == 'closed' ) {
530538 $infopage->mSubStatus = 'imported';
531 - $wgOut->addHtml( $infopage->showIncubatingWiki() );
 539+ $wgOut->addHtml( $infopage->showIncubatingWiki() );
532540 } else {
533541 $wgOut->addHtml( $infopage->showMissingWiki() );
534542 }
Index: trunk/extensions/WikimediaIncubator/InfoPage.php
@@ -19,6 +19,11 @@
2020 */
2121
2222 class InfoPage {
 23+
 24+ /**
 25+ * @param $title Title
 26+ * @param $prefixdata
 27+ */
2328 public function __construct( $title, $prefixdata ) {
2429 global $wmincProjects, $wmincSisterProjects;
2530 $this->mTitle = $title;
@@ -54,9 +59,9 @@
5560 $useUrl = $url ? $url : IncubatorTest::getSubdomain( 'www', IncubatorTest::getProject( $project, false, true ) );
5661 if ( !$imageobj ) { # image not found
5762 if( !$clickable ) {
58 - return $logo;
 63+ return $logo; // FIXME: $logo is undefined
5964 }
60 - return Linker::makeExternalLink( $useUrl, $project, false );
 65+ return Linker::makeExternalLink( $useUrl, $project, false );
6166 }
6267 if( $clickable ) {
6368 $args['link-url'] = $useUrl;
@@ -79,6 +84,7 @@
8085 public function listOtherProjects() {
8186 global $wmincProjects, $wmincSisterProjects;
8287 $otherProjects = $wmincProjects + $wmincSisterProjects;
 88+ $listOtherProjects = array();
8389 foreach( $otherProjects as $code => $name ) {
8490 $listOtherProjects[$code] = '<li>' . $this->makeLogo( $name, true,
8591 75, null, IncubatorTest::getSubdomain( $this->mLangCode, $code ) ) . '</li>';
@@ -94,7 +100,8 @@
95101 */
96102 public function listMultilingualProjects() {
97103 global $wmincMultilingualProjects;
98 - if( !is_array( $wmincMultilingualProjects ) ) { return; }
 104+ if( !is_array( $wmincMultilingualProjects ) ) { return ''; }
 105+ $list = array();
99106 foreach( $wmincMultilingualProjects as $url => $name ) {
100107 $list[$url] = '<li>' . $this->makeLogo( $name, true,
101108 75, null, '//'.$url.'/') . '</li>';
@@ -136,7 +143,7 @@
137144 array( 'class' => 'wminc-infopage-status' ),
138145 wfMsgWikiHtml( 'wminc-infopage-missingwiki-text',
139146 $this->mProjectName, $this->mLangName )
140 - ) .
 147+ ) .
141148 Html::rawElement( 'ul', array( 'class' => 'wminc-infopage-options' ),
142149 Html::rawElement( 'li', null,
143150 wfMsgExt( $this->mIsSister ? 'wminc-infopage-option-startsister' : 'wminc-infopage-option-startwiki',
@@ -209,4 +216,4 @@
210217 );
211218 return $this->StandardInfoPage( $this->showWelcome(), $gotoSubdomain, $content );
212219 }
213 -}
\ No newline at end of file
 220+}

Follow-up revisions

RevisionCommit summaryAuthorDate
r105776MFT for WikimediaIncubator: r95582, r96122, r96138, r96141, r97175, r98670, r...siebrand00:32, 11 December 2011

Status & tagging log