Parent5446 has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/148144

Change subject: Make UserNotLoggedIn redirect to login page
......................................................................

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: Idd9325374cb5dc13c4c057f45f88a33bdff523a9
---
M includes/exception/UserNotLoggedIn.php
1 file changed, 16 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/44/148144/1

diff --git a/includes/exception/UserNotLoggedIn.php 
b/includes/exception/UserNotLoggedIn.php
index 9d89009..f7a56b5 100644
--- a/includes/exception/UserNotLoggedIn.php
+++ b/includes/exception/UserNotLoggedIn.php
@@ -62,4 +62,20 @@
        ) {
                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();
+       }
 }

-- 
To view, visit https://gerrit.wikimedia.org/r/148144
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Idd9325374cb5dc13c4c057f45f88a33bdff523a9
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Parent5446 <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to