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
) {
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();
+ }
}