r70957 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r70956‎ | r70957 | r70958 >
Date:14:25, 12 August 2010
Author:platonides
Status:ok (Comments)
Tags:
Comment:
Refactor to avoid defining globals inside switches.
Modified paths:
  • /trunk/phase3/includes/Autopromote.php (modified) (history)
  • /trunk/phase3/includes/api/ApiBase.php (modified) (history)
  • /trunk/phase3/includes/api/ApiEditPage.php (modified) (history)
  • /trunk/phase3/includes/api/ApiLogin.php (modified) (history)
  • /trunk/phase3/includes/api/ApiUpload.php (modified) (history)
  • /trunk/phase3/maintenance/dumpTextPass.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/dumpTextPass.php
@@ -80,11 +80,11 @@
8181 }
8282
8383 function processOption( $opt, $val, $param ) {
 84+ global $IP;
8485 $url = $this->processFileOpt( $val, $param );
8586
8687 switch( $opt ) {
8788 case 'prefetch':
88 - global $IP;
8989 require_once "$IP/maintenance/backupPrefetch.inc";
9090 $this->prefetch = new BaseDump( $url );
9191 break;
Index: trunk/phase3/includes/api/ApiEditPage.php
@@ -252,6 +252,8 @@
253253
254254 $retval = $ep->internalAttemptSave( $result, $wgUser->isAllowed( 'bot' ) && $params['bot'] );
255255 $wgRequest = $oldRequest;
 256+ global $wgMaxArticleSize;
 257+
256258 switch( $retval ) {
257259 case EditPage::AS_HOOK_ERROR:
258260 case EditPage::AS_HOOK_ERROR_EXPECTED:
@@ -274,7 +276,6 @@
275277
276278 case EditPage::AS_MAX_ARTICLE_SIZE_EXCEEDED:
277279 case EditPage::AS_CONTENT_TOO_BIG:
278 - global $wgMaxArticleSize;
279280 $this->dieUsageMsg( array( 'contenttoobig', $wgMaxArticleSize ) );
280281
281282 case EditPage::AS_READ_ONLY_PAGE_ANON:
Index: trunk/phase3/includes/api/ApiLogin.php
@@ -70,12 +70,10 @@
7171
7272 $loginForm = new LoginForm( $req );
7373
74 - global $wgCookiePrefix;
 74+ global $wgCookiePrefix, $wgUser, $wgPasswordAttemptThrottle;;
7575
7676 switch ( $authRes = $loginForm->authenticateUserData() ) {
7777 case LoginForm::SUCCESS:
78 - global $wgUser;
79 -
8078 $wgUser->setOption( 'rememberpassword', 1 );
8179 $wgUser->setCookies();
8280
@@ -134,7 +132,6 @@
135133 break;
136134
137135 case LoginForm::THROTTLED:
138 - global $wgPasswordAttemptThrottle;
139136 $result['result'] = 'Throttled';
140137 $result['wait'] = intval( $wgPasswordAttemptThrottle['seconds'] );
141138 break;
Index: trunk/phase3/includes/api/ApiBase.php
@@ -550,6 +550,7 @@
551551 * @returns mixed
552552 */
553553 protected function getWatchlistValue ( $watchlist, $titleObj, $userOption = null ) {
 554+ global $wgUser;
554555 switch ( $watchlist ) {
555556 case 'watch':
556557 return true;
@@ -558,7 +559,6 @@
559560 return false;
560561
561562 case 'preferences':
562 - global $wgUser;
563563 # If the user is already watching, don't bother checking
564564 if ( $titleObj->userIsWatching() ) {
565565 return null;
Index: trunk/phase3/includes/api/ApiUpload.php
@@ -167,6 +167,8 @@
168168 * Performs file verification, dies on error.
169169 */
170170 protected function verifyUpload( ) {
 171+ global $wgFileExtensions;
 172+
171173 $verification = $this->mUpload->verifyUpload( );
172174 if ( $verification['status'] === UploadBase::OK ) {
173175 return;
@@ -184,7 +186,6 @@
185187 $this->dieUsage( 'The file is missing an extension', 'filetype-missing' );
186188 break;
187189 case UploadBase::FILETYPE_BADTYPE:
188 - global $wgFileExtensions;
189190 $this->dieUsage( 'This type of file is banned', 'filetype-banned',
190191 0, array(
191192 'filetype' => $verification['finalExt'],
Index: trunk/phase3/includes/Autopromote.php
@@ -104,6 +104,7 @@
105105 * @return bool Whether the condition is true for the user
106106 */
107107 private static function checkCondition( $cond, User $user ) {
 108+ global $wgEmailAuthentication;
108109 if ( count( $cond ) < 1 ) {
109110 return false;
110111 }
@@ -111,7 +112,6 @@
112113 switch( $cond[0] ) {
113114 case APCOND_EMAILCONFIRMED:
114115 if ( User::isValidEmailAddr( $user->getEmail() ) ) {
115 - global $wgEmailAuthentication;
116116 if ( $wgEmailAuthentication ) {
117117 return (bool)$user->getEmailAuthenticationTimestamp();
118118 } else {

Follow-up revisions

RevisionCommit summaryAuthorDate
r72751Follow up r70957. Remove the double semicolon.platonides20:45, 10 September 2010

Comments

#Comment by Bryan (talk | contribs)   19:35, 10 September 2010

Double semicolon, but whatever.

#Comment by Platonides (talk | contribs)   20:45, 10 September 2010

Removed in r72751.

Status & tagging log