specials: Simplify return logic of various SpecialUserlogin methods
authorTimo Tijhof <krinklemail@gmail.com>
Sun, 31 May 2015 15:30:01 +0000 (16:30 +0100)
committerTimo Tijhof <krinklemail@gmail.com>
Sun, 14 Jun 2015 02:27:17 +0000 (03:27 +0100)
* Handle exceptional case before common case in makeLanguageSelector
  by using early returns. Better reflects the intended effect
  of the exception by making it harder to accidentally run code
  after the 'else' statement.

Change-Id: I710a94adf22bc4e6dc539e12c69e4ba96bf1068c

includes/specials/SpecialUserlogin.php

index 64a6f72..8259718 100644 (file)
@@ -1529,7 +1529,6 @@ class LoginForm extends SpecialPage {
         */
        public static function getCreateaccountToken() {
                global $wgRequest;
-
                return $wgRequest->getSessionData( 'wsCreateaccountToken' );
        }
 
@@ -1604,22 +1603,21 @@ class LoginForm extends SpecialPage {
         */
        function makeLanguageSelector() {
                $msg = $this->msg( 'loginlanguagelinks' )->inContentLanguage();
-               if ( !$msg->isBlank() ) {
-                       $langs = explode( "\n", $msg->text() );
-                       $links = array();
-                       foreach ( $langs as $lang ) {
-                               $lang = trim( $lang, '* ' );
-                               $parts = explode( '|', $lang );
-                               if ( count( $parts ) >= 2 ) {
-                                       $links[] = $this->makeLanguageSelectorLink( $parts[0], trim( $parts[1] ) );
-                               }
-                       }
-
-                       return count( $links ) > 0 ? $this->msg( 'loginlanguagelabel' )->rawParams(
-                               $this->getLanguage()->pipeList( $links ) )->escaped() : '';
-               } else {
+               if ( $msg->isBlank() ) {
                        return '';
                }
+               $langs = explode( "\n", $msg->text() );
+               $links = array();
+               foreach ( $langs as $lang ) {
+                       $lang = trim( $lang, '* ' );
+                       $parts = explode( '|', $lang );
+                       if ( count( $parts ) >= 2 ) {
+                               $links[] = $this->makeLanguageSelectorLink( $parts[0], trim( $parts[1] ) );
+                       }
+               }
+
+               return count( $links ) > 0 ? $this->msg( 'loginlanguagelabel' )->rawParams(
+                       $this->getLanguage()->pipeList( $links ) )->escaped() : '';
        }
 
        /**