From f5b9a5d64c8ab38d63eb6c46b7ef6a9879605d8f Mon Sep 17 00:00:00 2001 From: Kunal Mehta Date: Sun, 15 Apr 2018 17:02:19 -0700 Subject: [PATCH] Let special pages redirect to the login page themselves SkinMinerva::getPersonalUrl() is supposed to link to the login page if the user isn't logged in, building a URL that will redirect them back to the proper special page. Except the two special pages that use this function will already automatically redirect to the login page if you're not logged in. Manually handling the redirect requries additional complexity, and duplication of things like message keys. Change-Id: Id5bfca1049f84e52476b179b8fdda50d030d7c1c --- includes/skins/SkinMinerva.php | 33 ++------------------------------- 1 file changed, 2 insertions(+), 31 deletions(-) diff --git a/includes/skins/SkinMinerva.php b/includes/skins/SkinMinerva.php index 031d524..7a02306 100644 --- a/includes/skins/SkinMinerva.php +++ b/includes/skins/SkinMinerva.php @@ -449,28 +449,6 @@ class SkinMinerva extends SkinTemplate implements ICustomizableSkin { } } - /** - * Return a url to a resource or to a login screen that redirects to that resource. - * @param Title $title - * @param string $warning Key of message to display on login page (optional) - * @param array $query representation of query string parameters (optional) - * @return string url - */ - protected function getPersonalUrl( Title $title, $warning, array $query = [] ) { - if ( $this->getUser()->isLoggedIn() ) { - return $title->getLocalUrl( $query ); - } else { - $loginQueryParams['returnto'] = $title; - if ( $query ) { - $loginQueryParams['returntoquery'] = wfArrayToCgi( $query ); - } - if ( $warning ) { - $loginQueryParams['warning'] = $warning; - } - return $this->getLoginUrl( $loginQueryParams ); - } - } - /** * Inserts the Contributions menu item into the menu. * @@ -513,11 +491,7 @@ class SkinMinerva extends SkinTemplate implements ICustomizableSkin { $menu->insert( 'watchlist', $isJSOnly = true ) ->addComponent( $this->msg( 'mobile-frontend-main-menu-watchlist' )->escaped(), - $this->getPersonalUrl( - $watchTitle, - 'mobile-frontend-watchlist-purpose', - $watchlistQuery - ), + $watchTitle->getLocalURL( $watchlistQuery ), MinervaUI::iconClass( 'watchlist', 'before' ), [ 'data-event-name' => 'watchlist' ] ); @@ -551,10 +525,7 @@ class SkinMinerva extends SkinTemplate implements ICustomizableSkin { $menu->insert( 'preferences' ) ->addComponent( $this->msg( 'preferences' )->escaped(), - $this->getPersonalUrl( - SpecialPage::getTitleFor( 'Preferences' ), - 'prefsnologintext2' - ), + SpecialPage::getTitleFor( 'Preferences' )->getLocalURL(), MinervaUI::iconClass( 'settings', 'before' ), [ 'data-event-name' => 'preferences' ] );