Make Special:Redirect able to redirect by page ID
authorThis, that and the other <at.light@live.com.au>
Fri, 20 Dec 2013 05:46:58 +0000 (16:46 +1100)
committerThis, that and the other <at.light@live.com.au>
Fri, 20 Dec 2013 05:47:32 +0000 (16:47 +1100)
A fairly simple change.

Bug: 58727
Change-Id: Id030728e7c1449f0ff856be10a972bea5bdd18f6

includes/specials/SpecialRedirect.php
languages/messages/MessagesEn.php
languages/messages/MessagesQqq.php
maintenance/language/messages.inc

index f05dacb..8ec6f85 100644 (file)
@@ -135,6 +135,25 @@ class SpecialRedirect extends FormSpecialPage {
                ) );
        }
 
+       /**
+        * Handle Special:Redirect/page/xxx (by redirecting to index.php?curid=xxx)
+        *
+        * @return string|null url to redirect to, or null if $mValue is invalid.
+        */
+       function dispatchPage() {
+               $curid = $this->mValue;
+               if ( !ctype_digit( $curid ) ) {
+                       return null;
+               }
+               $curid = (int)$curid;
+               if ( $curid === 0 ) {
+                       return null;
+               }
+               return wfAppendQuery( wfScript( 'index' ), array(
+                       'curid' => $curid
+               ) );
+       }
+
        /**
         * Use appropriate dispatch* method to obtain a redirection URL,
         * and either: redirect, set a 404 error code and error message,
@@ -155,6 +174,9 @@ class SpecialRedirect extends FormSpecialPage {
                case 'revision':
                        $url = $this->dispatchRevision();
                        break;
+               case 'page':
+                       $url = $this->dispatchPage();
+                       break;
                default:
                        $this->getOutput()->setStatusCode( 404 );
                        $url = null;
@@ -177,8 +199,10 @@ class SpecialRedirect extends FormSpecialPage {
                $mp = $this->getMessagePrefix();
                $ns = array(
                        // subpage => message
-                       // Messages: redirect-user, redirect-revision, redirect-file
+                       // Messages: redirect-user, redirect-page, redirect-revision,
+                       // redirect-file
                        'user' => $mp . '-user',
+                       'page' => $mp . '-page',
                        'revision' => $mp . '-revision',
                        'file' => $mp . '-file',
                );
index 0fe59e0..287f7c4 100644 (file)
@@ -4838,15 +4838,16 @@ You should have received [{{SERVER}}{{SCRIPTPATH}}/COPYING a copy of the GNU Gen
 'version-entrypoints-load-php'          => '[https://www.mediawiki.org/wiki/Manual:load.php load.php]', # do not translate or duplicate this message to other languages
 
 # Special:Redirect
-'redirect'            => 'Redirect by file, user, or revision ID',
+'redirect'            => 'Redirect by file, user, page or revision ID',
 'redirect-legend'     => 'Redirect to a file or page',
 'redirect-text'       => '', # do not translate or duplicate this message to other languages
-'redirect-summary'    => 'This special page redirects to a file (given the file name), a page (given a revision ID), or a user page (given a numeric user ID). Usage: [[{{#Special:Redirect}}/file/Example.jpg]], [[{{#Special:Redirect}}/revision/328429]], or [[{{#Special:Redirect}}/user/101]].',
+'redirect-summary'    => 'This special page redirects to a file (given the file name), a page (given a revision ID or page ID), or a user page (given a numeric user ID). Usage: [[{{#Special:Redirect}}/file/Example.jpg]], [[{{#Special:Redirect}}/page/64308]], [[{{#Special:Redirect}}/revision/328429]], or [[{{#Special:Redirect}}/user/101]].',
 'redirect-submit'     => 'Go',
 'redirect-lookup'     => 'Lookup:',
 'redirect-value'      => 'Value:',
 'redirect-user'       => 'User ID',
 'redirect-revision'   => 'Page revision',
+'redirect-page'       => 'Page ID',
 'redirect-file'       => 'File name',
 'redirect-not-exists' => 'Value not found',
 
index e3e574a..cad47a5 100644 (file)
@@ -9957,7 +9957,7 @@ A short description of the script path entry point. Links to the mediawiki.org d
 
 # Special:Redirect
 'redirect' => "{{doc-special|Redirect}}
-This means \"Redirect by file'''name''', user '''ID''', or revision ID\".",
+This means \"Redirect by file'''name''', user '''ID''', page ID, or revision ID\".",
 'redirect-legend' => 'Legend of fieldset around input box in [[Special:Redirect]]',
 'redirect-summary' => 'Shown at top of [[Special:Redirect]]',
 'redirect-submit' => 'Button label in [[Special:Redirect]].
@@ -9966,12 +9966,14 @@ This means \"Redirect by file'''name''', user '''ID''', or revision ID\".",
 
 Followed by the select box which has the following options:
 * {{msg-mw|Redirect-user}}
+* {{msg-mw|Redirect-page}}
 * {{msg-mw|Redirect-revision}}
 * {{msg-mw|Redirect-file}}',
 'redirect-value' => 'Second field label in [[Special:Redirect]]
 {{Identical|Value}}',
 'redirect-user' => 'Description of lookup type for [[Special:Redirect]].
 {{Identical|User ID}}',
+'redirect-page' => 'Description of lookup type for [[Special:Redirect]].',
 'redirect-revision' => "Description of lookup type for [[Special:Redirect]].
 
 This means \"Page revision '''ID'''\".",
index aeb9453..d0af5e4 100644 (file)
@@ -3685,6 +3685,7 @@ $wgMessageStructure = array(
                'redirect-lookup',
                'redirect-value',
                'redirect-user',
+               'redirect-page',
                'redirect-revision',
                'redirect-file',
                'redirect-not-exists',