From: Tyler Romeo Date: Tue, 15 Jul 2014 18:48:09 +0000 (-0400) Subject: Make UserNotLoggedIn redirect to login page X-Git-Tag: 1.31.0-rc.0~14933^2~1 X-Git-Url: http://git.cyclocoop.org/%24href?a=commitdiff_plain;h=e0af129cbdb7421b4d9d7858cc63125e12f35a4a;p=lhc%2Fweb%2Fwiklou.git Make UserNotLoggedIn redirect to login page For pages like Special:Watchlist that throw a UserNotLoggedIn exception when the user is anonymous, this patch makes the page redirect to the login page automatically. This is instead of the current behavior of showing a link to the login page that the user must click. (Also, Special:Userlogin has existing functionality that will redirect the user back once they are logged in.) Bug: 15484 Change-Id: Ic7e1d5a8984e1b42c8f2ebceff094106a3ed1efa --- diff --git a/includes/exception/UserNotLoggedIn.php b/includes/exception/UserNotLoggedIn.php index 9d89009100..f7a56b5091 100644 --- a/includes/exception/UserNotLoggedIn.php +++ b/includes/exception/UserNotLoggedIn.php @@ -62,4 +62,20 @@ class UserNotLoggedIn extends ErrorPageError { ) { parent::__construct( $titleMsg, $reasonMsg, $params ); } + + /** + * Redirect to Special:Userlogin + */ + public function report() { + $context = RequestContext::getMain(); + + $output = $context->getOutput(); + $output->redirect( SpecialPage::getTitleFor( 'Userlogin' )->getFullURL( array( + // Return to this page when the user logs in + 'returnto' => $context->getTitle()->getText(), + 'returntoquery' => wfArrayToCgi( $context->getRequest()->getValues() ) + ) ) ); + + $output->output(); + } }