From 3d1e04e976ccb27e22e71ee0cd8ba53ee2d90780 Mon Sep 17 00:00:00 2001 From: Florian Date: Sun, 22 May 2016 01:20:08 +0200 Subject: [PATCH] LoginSignupSpecialPage: Load return and returnto params as early as possible 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 --- .../specialpage/LoginSignupSpecialPage.php | 42 +++++++++++++++---- 1 file changed, 33 insertions(+), 9 deletions(-) diff --git a/includes/specialpage/LoginSignupSpecialPage.php b/includes/specialpage/LoginSignupSpecialPage.php index 0e4252c9e8..a7de0c58f4 100644 --- a/includes/specialpage/LoginSignupSpecialPage.php +++ b/includes/specialpage/LoginSignupSpecialPage.php @@ -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 */ -- 2.20.1