From 9d323de4c5e88eb85a497203d15c254e4a258aa7 Mon Sep 17 00:00:00 2001 From: Timo Tijhof Date: Sun, 31 May 2015 16:30:01 +0100 Subject: [PATCH] specials: Simplify return logic of various SpecialUserlogin methods * 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 | 28 ++++++++++++-------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/includes/specials/SpecialUserlogin.php b/includes/specials/SpecialUserlogin.php index 64a6f7244e..8259718e6f 100644 --- a/includes/specials/SpecialUserlogin.php +++ b/includes/specials/SpecialUserlogin.php @@ -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() : ''; } /** -- 2.20.1