Fix checks to pass or display "return to" links in Special:UserLogin.
authorAlexandre Emsenhuber <ialex.wiki@gmail.com>
Wed, 8 Aug 2012 10:04:42 +0000 (12:04 +0200)
committerAlexandre Emsenhuber <ialex.wiki@gmail.com>
Wed, 8 Aug 2012 10:13:17 +0000 (12:13 +0200)
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

index 6f82fad..0c72b76 100644 (file)
@@ -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;
                }