(bug 5284) Special redirect pages should remember parameters
This commit is contained in:
parent
c25c53f443
commit
6ae9987277
2 changed files with 37 additions and 4 deletions
|
|
@ -152,6 +152,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
|
|||
* (bug 5757) Fix premature cutoff in LanguageConverter with extra end markers
|
||||
* (bug 5516) Show appropriate "return to" link on blocked page
|
||||
* (bug 5377) Do not auto-login when creating an account as another user
|
||||
* (bug 5284) Special redirect pages should remember parameters
|
||||
|
||||
== Compatibility ==
|
||||
|
||||
|
|
|
|||
|
|
@ -195,6 +195,33 @@ class SpecialPage
|
|||
return isset( $redirects[$name] ) ? $redirects[$name] : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return part of the request string for a special redirect page
|
||||
* This allows passing, e.g. action=history to Special:Mypage, etc.
|
||||
*
|
||||
* @param $name Name of the redirect page
|
||||
* @return string
|
||||
*/
|
||||
function getRedirectParams( $name ) {
|
||||
global $wgRequest;
|
||||
|
||||
$args = array();
|
||||
switch( $name ) {
|
||||
case 'Mypage':
|
||||
case 'Mytalk':
|
||||
case 'Randompage':
|
||||
$args = array( 'action' );
|
||||
}
|
||||
|
||||
$params = array();
|
||||
foreach( $args as $arg ) {
|
||||
if( $val = $wgRequest->getVal( $arg, false ) )
|
||||
$params[] = $arg . '=' . $val;
|
||||
}
|
||||
|
||||
return count( $params ) ? implode( '&', $params ) : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return categorised listable special pages
|
||||
* Returns a 2d array where the first index is the restriction name
|
||||
|
|
@ -248,10 +275,15 @@ class SpecialPage
|
|||
} else {
|
||||
$redir = SpecialPage::getRedirect( $name );
|
||||
if ( isset( $redir ) ) {
|
||||
if ( isset( $par ) )
|
||||
$wgOut->redirect( $redir->getFullURL() . '/' . $par );
|
||||
else
|
||||
$wgOut->redirect( $redir->getFullURL() );
|
||||
$params = SpecialPage::getRedirectParams( $name );
|
||||
if( $params ) {
|
||||
$url = $redir->getFullUrl( $params );
|
||||
} elseif( $par ) {
|
||||
$url = $redir->getFullUrl() . '/' . $par;
|
||||
} else {
|
||||
$url = $redir->getFullUrl();
|
||||
}
|
||||
$wgOut->redirect( $url );
|
||||
$retVal = $redir;
|
||||
} else {
|
||||
$wgOut->setArticleRelated( false );
|
||||
|
|
|
|||
Loading…
Reference in a new issue