(bug 5284) Special redirect pages should remember parameters
authorRob Church <robchurch@users.mediawiki.org>
Sun, 30 Apr 2006 02:27:43 +0000 (02:27 +0000)
committerRob Church <robchurch@users.mediawiki.org>
Sun, 30 Apr 2006 02:27:43 +0000 (02:27 +0000)
RELEASE-NOTES
includes/SpecialPage.php

index 8bb3d64..fb36547 100644 (file)
@@ -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 ==
 
index a0eca5a..56992bb 100644 (file)
@@ -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 );