From: Rob Church Date: Sun, 30 Apr 2006 02:27:43 +0000 (+0000) Subject: (bug 5284) Special redirect pages should remember parameters X-Git-Tag: 1.31.0-rc.0~57316 X-Git-Url: http://git.cyclocoop.org/url?a=commitdiff_plain;h=6ae998727797e0390c1fc1b035797c56f6df7d8f;p=lhc%2Fweb%2Fwiklou.git (bug 5284) Special redirect pages should remember parameters --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 8bb3d64c4e..fb36547316 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -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 == diff --git a/includes/SpecialPage.php b/includes/SpecialPage.php index a0eca5a9bc..56992bb30b 100644 --- a/includes/SpecialPage.php +++ b/includes/SpecialPage.php @@ -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 );