(bug 24330) Add &redirect parameter to ?action=edit
authorX! <soxred93@users.mediawiki.org>
Sun, 8 Aug 2010 01:14:48 +0000 (01:14 +0000)
committerX! <soxred93@users.mediawiki.org>
Sun, 8 Aug 2010 01:14:48 +0000 (01:14 +0000)
RELEASE-NOTES
includes/api/ApiEditPage.php

index 2579818..319c3c2 100644 (file)
@@ -331,7 +331,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * (bug 24677) axto= parameters added to allcategories, allimages, alllinks, allmessages, 
   allpages, and allusers
 * (bug 24236) Add add, remove, add-self, remove-self tags to meta=siteinfo&siprop=usergroups
-* (bug 24484) Add prop=pageprops module   
+* (bug 24484) Add prop=pageprops module 
+* (bug 24330) Add &redirect parameter to ?action=edit  
 
 === Languages updated in 1.17 ===
 
index 159d1cc..1c165b6 100644 (file)
@@ -57,6 +57,37 @@ class ApiEditPage extends ApiBase {
                if ( !$titleObj || $titleObj->isExternal() ) {
                        $this->dieUsageMsg( array( 'invalidtitle', $params['title'] ) );
                }
+               
+               if( $params['redirect'] ) {
+                       if( $titleObj->isRedirect() ) {
+                               $oldTitle = $titleObj;
+                               
+                               $titles = Title::newFromRedirectArray( Revision::newFromTitle( $oldTitle )->getText( Revision::FOR_THIS_USER ) );
+                               //array_shift( $titles );
+                               
+                               $this->getResult()->addValue( null, 'foo', $titles );
+                               
+                               
+                               $redirValues = array();
+                               foreach ( $titles as $id => $newTitle ) {
+                                       
+                                       if( !isset( $titles[ $id - 1 ] ) ) {
+                                               $titles[ $id - 1 ] = $oldTitle;
+                                       }
+                                       
+                                       $redirValues[] = array(
+                                               'from' => $titles[ $id - 1 ]->getPrefixedText(),
+                                               'to' => $newTitle->getPrefixedText()
+                                       );
+                                       
+                                       $titleObj = $newTitle;
+                               }
+               
+                               $this->getResult()->setIndexedTagName( $redirValues, 'r' );
+                               $this->getResult()->addValue( null, 'redirects', $redirValues );
+
+                       }
+               }
 
                // Some functions depend on $wgTitle == $ep->mTitle
                global $wgTitle;
@@ -428,6 +459,10 @@ class ApiEditPage extends ApiBase {
                        'undoafter' => array(
                                ApiBase::PARAM_TYPE => 'integer'
                        ),
+                       'redirect' => array(
+                               ApiBase::PARAM_TYPE => 'boolean',
+                               ApiBase::PARAM_DFLT => false,
+                       ),
                );
        }
 
@@ -462,6 +497,7 @@ class ApiEditPage extends ApiBase {
                        'appendtext' => "Add this text to the end of the page. Overrides {$p}text",
                        'undo' => "Undo this revision. Overrides {$p}text, {$p}prependtext and {$p}appendtext",
                        'undoafter' => 'Undo all revisions from undo to this one. If not set, just undo one revision',
+                       'redirect' => 'Automatically resolve redirects',
                );
        }