From 56dbeaa4482ff031f8d270f65c66462375e4a1df Mon Sep 17 00:00:00 2001 From: Alexandre Emsenhuber Date: Wed, 8 Aug 2012 12:04:42 +0200 Subject: [PATCH] Fix checks to pass or display "return to" links in Special:UserLogin. Currently it is not possible to have a "return to" link to the page "0" because "empty( '0' )" is true. - Groupped mReturnTo and mReturnToQuery definitions for better consistency. - Changed default value of those members from null to '' when they are not provided so that it's easier to make strict comparison - Changed empty() checks to strict comparison with '' to correctly display the links in the case mentionned above Change-Id: I2714ba1c5654f6ea6ddb195eef0c7464893224e0 --- includes/specials/SpecialUserlogin.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/includes/specials/SpecialUserlogin.php b/includes/specials/SpecialUserlogin.php index 6f82faddc9..0c72b76316 100644 --- a/includes/specials/SpecialUserlogin.php +++ b/includes/specials/SpecialUserlogin.php @@ -93,8 +93,6 @@ class LoginForm extends SpecialPage { $this->mRetype = $request->getText( 'wpRetype' ); $this->mDomain = $request->getText( 'wpDomain' ); $this->mReason = $request->getText( 'wpReason' ); - $this->mReturnTo = $request->getVal( 'returnto' ); - $this->mReturnToQuery = $request->getVal( 'returntoquery' ); $this->mCookieCheck = $request->getVal( 'wpCookieCheck' ); $this->mPosted = $request->wasPosted(); $this->mCreateaccount = $request->getCheck( 'wpCreateaccount' ); @@ -111,6 +109,9 @@ class LoginForm extends SpecialPage { if ( $wgRedirectOnLogin ) { $this->mReturnTo = $wgRedirectOnLogin; $this->mReturnToQuery = ''; + } else { + $this->mReturnTo = $request->getVal( 'returnto', '' ); + $this->mReturnToQuery = $request->getVal( 'returntoquery', '' ); } if( $wgEnableEmail ) { @@ -916,7 +917,7 @@ class LoginForm extends SpecialPage { $out->addHTML( $injected_html ); - if ( !empty( $this->mReturnTo ) ) { + if ( $this->mReturnTo !== '' ) { $out->returnToMain( null, $this->mReturnTo, $this->mReturnToQuery ); } else { $out->returnToMain( null ); @@ -1004,9 +1005,9 @@ class LoginForm extends SpecialPage { $linkmsg = 'nologin'; } - if ( !empty( $this->mReturnTo ) ) { + if ( $this->mReturnTo !== '' ) { $returnto = '&returnto=' . wfUrlencode( $this->mReturnTo ); - if ( !empty( $this->mReturnToQuery ) ) { + if ( $this->mReturnToQuery !== '' ) { $returnto .= '&returntoquery=' . wfUrlencode( $this->mReturnToQuery ); } @@ -1196,7 +1197,7 @@ class LoginForm extends SpecialPage { function cookieRedirectCheck( $type ) { $titleObj = SpecialPage::getTitleFor( 'Userlogin' ); $query = array( 'wpCookieCheck' => $type ); - if ( $this->mReturnTo ) { + if ( $this->mReturnTo !== '' ) { $query['returnto'] = $this->mReturnTo; $query['returntoquery'] = $this->mReturnToQuery; } -- 2.20.1