r13956 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r13955‎ | r13956 | r13957 >
Date:02:27, 30 April 2006
Author:robchurch
Status:old
Tags:
Comment:
(bug 5284) Special redirect pages should remember parameters
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/SpecialPage.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/SpecialPage.php
@@ -196,6 +196,33 @@
197197 }
198198
199199 /**
 200+ * Return part of the request string for a special redirect page
 201+ * This allows passing, e.g. action=history to Special:Mypage, etc.
 202+ *
 203+ * @param $name Name of the redirect page
 204+ * @return string
 205+ */
 206+ function getRedirectParams( $name ) {
 207+ global $wgRequest;
 208+
 209+ $args = array();
 210+ switch( $name ) {
 211+ case 'Mypage':
 212+ case 'Mytalk':
 213+ case 'Randompage':
 214+ $args = array( 'action' );
 215+ }
 216+
 217+ $params = array();
 218+ foreach( $args as $arg ) {
 219+ if( $val = $wgRequest->getVal( $arg, false ) )
 220+ $params[] = $arg . '=' . $val;
 221+ }
 222+
 223+ return count( $params ) ? implode( '&', $params ) : false;
 224+ }
 225+
 226+ /**
200227 * Return categorised listable special pages
201228 * Returns a 2d array where the first index is the restriction name
202229 * @static
@@ -248,10 +275,15 @@
249276 } else {
250277 $redir = SpecialPage::getRedirect( $name );
251278 if ( isset( $redir ) ) {
252 - if ( isset( $par ) )
253 - $wgOut->redirect( $redir->getFullURL() . '/' . $par );
254 - else
255 - $wgOut->redirect( $redir->getFullURL() );
 279+ $params = SpecialPage::getRedirectParams( $name );
 280+ if( $params ) {
 281+ $url = $redir->getFullUrl( $params );
 282+ } elseif( $par ) {
 283+ $url = $redir->getFullUrl() . '/' . $par;
 284+ } else {
 285+ $url = $redir->getFullUrl();
 286+ }
 287+ $wgOut->redirect( $url );
256288 $retVal = $redir;
257289 } else {
258290 $wgOut->setArticleRelated( false );
Index: trunk/phase3/RELEASE-NOTES
@@ -152,6 +152,7 @@
153153 * (bug 5757) Fix premature cutoff in LanguageConverter with extra end markers
154154 * (bug 5516) Show appropriate "return to" link on blocked page
155155 * (bug 5377) Do not auto-login when creating an account as another user
 156+* (bug 5284) Special redirect pages should remember parameters
156157
157158 == Compatibility ==
158159

Follow-up revisions

RevisionCommit summaryAuthorDate
r14142(reopened bug 5284) Handle cases like Special:Mypage/monobook.js&action=editrobchurch15:22, 9 May 2006

Status & tagging log