LoginSignupSpecialPage: Load return and returnto params as early as possible
authorFlorian <florian.schmidt.stargatewissen@gmail.com>
Sat, 21 May 2016 23:20:08 +0000 (01:20 +0200)
committerFlorian <florian.schmidt.stargatewissen@gmail.com>
Sat, 28 May 2016 16:16:00 +0000 (18:16 +0200)
They're are needed for a redirect to the target page after
a successful login, which is made before the SpecialPage::execute()
function is called. Loading basic request varaibles in the execute()
function is therefore too late to take effect for the redirect after
a successul authentication with a primary provider, which needs to
redirect the user to another site.

Bug: T135924
Change-Id: I6ded7f9bb255cbb332a5810e7ed3cb3ecfdb2c04

includes/specialpage/LoginSignupSpecialPage.php

index 0e4252c..a7de0c5 100644 (file)
@@ -47,6 +47,7 @@ abstract class LoginSignupSpecialPage extends AuthManagerSpecialPage {
        protected $mEntryErrorType = 'error';
 
        protected $mLoaded = false;
+       protected $mLoadedRequest = false;
        protected $mSecureLoginUrl;
 
        /** @var string */
@@ -89,19 +90,20 @@ abstract class LoginSignupSpecialPage extends AuthManagerSpecialPage {
                $wgUseMediaWikiUIEverywhere = true;
        }
 
+       protected function setRequest( array $data, $wasPosted = null ) {
+               parent::setRequest( $data, $wasPosted );
+               $this->mLoadedRequest = false;
+       }
+
        /**
-        * Load data from request.
-        * @private
-        * @param string $subPage Subpage of Special:Userlogin
+        * Load basic request parameters for this Special page.
+        * @param $subPage
         */
-       protected function load( $subPage ) {
-               global $wgSecureLogin;
-
-               if ( $this->mLoaded ) {
+       private function loadRequestParameters( $subPage ) {
+               if ( $this->mLoadedRequest ) {
                        return;
                }
-               $this->mLoaded = true;
-
+               $this->mLoadedRequest = true;
                $request = $this->getRequest();
 
                $this->mPosted = $request->wasPosted();
@@ -114,6 +116,22 @@ abstract class LoginSignupSpecialPage extends AuthManagerSpecialPage {
                $this->mLanguage = $request->getText( 'uselang' );
                $this->mReturnTo = $request->getVal( 'returnto', '' );
                $this->mReturnToQuery = $request->getVal( 'returntoquery', '' );
+       }
+
+       /**
+        * Load data from request.
+        * @private
+        * @param string $subPage Subpage of Special:Userlogin
+        */
+       protected function load( $subPage ) {
+               global $wgSecureLogin;
+
+               $this->loadRequestParameters( $subPage );
+               if ( $this->mLoaded ) {
+                       return;
+               }
+               $this->mLoaded = true;
+               $request = $this->getRequest();
 
                $securityLevel = $this->getRequest()->getText( 'force' );
                if (
@@ -185,6 +203,12 @@ abstract class LoginSignupSpecialPage extends AuthManagerSpecialPage {
                return $params;
        }
 
+       protected function beforeExecute( $subPage ) {
+               // finish initializing the class before processing the request - T135924
+               $this->loadRequestParameters( $subPage );
+               return parent::beforeExecute( $subPage );
+       }
+
        /**
         * @param string|null $subPage
         */