Allow 'uselang', 'useskin', 'debug' as query parameters in RedirectSpecialPages
[lhc/web/wiklou.git] / includes / specialpage / RedirectSpecialPage.php
index 2e6e55a..df1fa61 100644 (file)
@@ -33,8 +33,11 @@ abstract class RedirectSpecialPage extends UnlistedSpecialPage {
        // Query parameters added by redirects
        protected $mAddedRedirectParams = array();
 
-       public function execute( $par ) {
-               $redirect = $this->getRedirect( $par );
+       /**
+        * @param string|null $subpage
+        */
+       public function execute( $subpage ) {
+               $redirect = $this->getRedirect( $subpage );
                $query = $this->getRedirectQuery();
                // Redirect to a page title with possible query parameters
                if ( $redirect instanceof Title ) {
@@ -58,22 +61,24 @@ abstract class RedirectSpecialPage extends UnlistedSpecialPage {
         * If the special page is a redirect, then get the Title object it redirects to.
         * False otherwise.
         *
-        * @param string $par Subpage string
+        * @param string|null $subpage
         * @return Title|bool
         */
-       abstract public function getRedirect( $par );
+       abstract public function getRedirect( $subpage );
 
        /**
         * Return part of the request string for a special redirect page
         * This allows passing, e.g. action=history to Special:Mypage, etc.
         *
-        * @return string
+        * @return array|bool
         */
        public function getRedirectQuery() {
                $params = array();
                $request = $this->getRequest();
 
-               foreach ( $this->mAllowedRedirectParams as $arg ) {
+               foreach ( array_merge( $this->mAllowedRedirectParams,
+                               array( 'uselang', 'useskin', 'debug' ) // parameters which can be passed to all pages
+                       ) as $arg ) {
                        if ( $request->getVal( $arg, null ) !== null ) {
                                $params[$arg] = $request->getVal( $arg );
                        } elseif ( $request->getArray( $arg, null ) !== null ) {
@@ -112,12 +117,16 @@ abstract class SpecialRedirectToSpecial extends RedirectSpecialPage {
                $this->mAddedRedirectParams = $addedRedirectParams;
        }
 
+       /**
+        * @param string|null $subpage
+        * @return Title|bool
+        */
        public function getRedirect( $subpage ) {
                if ( $this->redirSubpage === false ) {
                        return SpecialPage::getTitleFor( $this->redirName, $subpage );
-               } else {
-                       return SpecialPage::getTitleFor( $this->redirName, $this->redirSubpage );
                }
+
+               return SpecialPage::getTitleFor( $this->redirName, $this->redirSubpage );
        }
 }
 
@@ -198,7 +207,7 @@ abstract class RedirectSpecialArticle extends RedirectSpecialPage {
                        'section', 'oldid', 'diff', 'dir',
                        'limit', 'offset', 'feed',
                        # Misc options
-                       'redlink', 'debug',
+                       'redlink',
                        # Options for action=raw; missing ctype can break JS or CSS in some browsers
                        'ctype', 'maxage', 'smaxage',
                );