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
This commit is contained in:
Kunal Mehta 2018-04-15 17:02:19 -07:00 committed by Jdlrobson
parent 892adf0ea7
commit f5b9a5d64c
1 changed files with 2 additions and 31 deletions

View File

@ -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' ]
);