Merge "LoginSignupSpecialPage: Load return and returnto params as early as possible"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Sat, 28 May 2016 20:14:56 +0000 (20:14 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Sat, 28 May 2016 20:14:56 +0000 (20:14 +0000)
includes/specialpage/LoginSignupSpecialPage.php

index 0b5e70b..8dff163 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
         */