* (bug 25133) allow redirects also for action=parse&pageid
authorSam Reed <reedy@users.mediawiki.org>
Fri, 17 Jun 2011 15:57:00 +0000 (15:57 +0000)
committerSam Reed <reedy@users.mediawiki.org>
Fri, 17 Jun 2011 15:57:00 +0000 (15:57 +0000)
RELEASE-NOTES-1.19
includes/api/ApiParse.php

index 80f87df..2c078b2 100644 (file)
@@ -95,7 +95,7 @@ production.
 * (bug 29332) Warn if user requests mediawiki-announce subscription but does not
   enter an e-mail address.
 * (bug 25375) Add canonical namespaces to JavaScript "wgNamespaceIds"
-* The class JpegOrTiffHandler was renamed ExifBitmapHandler. 
+* The class JpegOrTiffHandler was renamed ExifBitmapHandler.
 
 === API changes in 1.19 ===
 * BREAKING CHANGE: action=watch now requires POST and token.
@@ -105,7 +105,7 @@ production.
 * (bug 28578) API's parse module should not silently override invalid
   title inputs
 * (bug 20699) API watchlist should list log-events
-* (bug 29070) Add token to action=watch API 
+* (bug 29070) Add token to action=watch API
 * (bug 29221) Expose oldrevid in watchlist output
 * (bug 29267) always give the servername for meta=siteinfo&siprop=dbrepllag
 * (bug 28897) rvparse doesn’t seem to work with rvsection
@@ -116,6 +116,7 @@ production.
 * (bug 21346) Make deleted images searchable by hash (disabled in Miser Mode)
 * (bug 27595) sha1 search of list=filearchive does not work
 * (bug 26763) Make RSS/Atom of user contributions more visible
+* (bug 25133) allow redirects also for action=parse&pageid
 
 === Languages updated in 1.19 ===
 
index 198083d..dfc2602 100644 (file)
@@ -110,35 +110,44 @@ class ApiParse extends ApiBase {
                                        $p_result = $wgParser->parse( $this->text, $titleObj, $popts );
                                }
                        } else { // Not $oldid
-                               if ( !is_null ( $pageid ) ) {
-                                       $titleObj = Title::newFromID( $pageid );
-
-                                       if ( !$titleObj ) {
-                                               $this->dieUsageMsg( array( 'nosuchpageid', $pageid ) );
+                               if ( $params['redirects'] ) {
+                                       $reqParams = array(
+                                               'action' => 'query',
+                                               'redirects' => '',
+                                       );
+                                       if ( !is_null ( $pageid ) ) {
+                                               $reqParams['pageids'] = $pageid;
+                                       } else { // $page
+                                               $reqParams['titles'] = $page;
                                        }
-                               } else { // $page
-                                       if ( $params['redirects'] ) {
-                                               $req = new FauxRequest( array(
-                                                       'action' => 'query',
-                                                       'redirects' => '',
-                                                       'titles' => $page
-                                               ) );
-                                               $main = new ApiMain( $req );
-                                               $main->execute();
-                                               $data = $main->getResultData();
-                                               $redirValues = isset( $data['query']['redirects'] )
-                                                       ? $data['query']['redirects'] : array();
-                                               $to = $page;
-                                               foreach ( (array)$redirValues as $r ) {
-                                                       $to = $r['to'];
-                                               }
-                                       } else {
-                                               $to = $page;
+                                       $req = new FauxRequest( $reqParams );
+                                       $main = new ApiMain( $req );
+                                       $main->execute();
+                                       $data = $main->getResultData();
+                                       $redirValues = isset( $data['query']['redirects'] )
+                                               ? $data['query']['redirects']
+                                               : array();
+                                       $to = $page;
+                                       foreach ( (array)$redirValues as $r ) {
+                                               $to = $r['to'];
                                        }
                                        $titleObj = Title::newFromText( $to );
-                                       if ( !$titleObj || !$titleObj->exists() ) {
-                                               $this->dieUsage( "The page you specified doesn't exist", 'missingtitle' );
+                               } else {
+                                       if ( !is_null ( $pageid ) ) {
+                                               $reqParams['pageids'] = $pageid;
+                                               $titleObj = Title::newFromID( $pageid );
+                                       } else { // $page
+                                               $to = $page;
+                                               $titleObj = Title::newFromText( $to );
+                                       }
+                               }
+                               if ( !is_null ( $pageid ) ) {
+                                       if ( !$titleObj ) {
+                                               // Still throw nosuchpageid error if pageid was provided
+                                               $this->dieUsageMsg( array( 'nosuchpageid', $pageid ) );
                                        }
+                               } elseif ( !$titleObj || !$titleObj->exists() ) {
+                                       $this->dieUsage( "The page you specified doesn't exist", 'missingtitle' );
                                }
                                $wgTitle = $titleObj;
 
@@ -515,7 +524,7 @@ class ApiParse extends ApiBase {
                return array(
                        'text' => 'Wikitext to parse',
                        'summary' => 'Summary to parse',
-                       'redirects' => "If the {$p}page parameter is set to a redirect, resolve it",
+                       'redirects' => "If the {$p}page or the {$p}pageid parameter is set to a redirect, resolve it",
                        'title' => 'Title of page the text belongs to',
                        'page' => "Parse the content of this page. Cannot be used together with {$p}text and {$p}title",
                        'pageid' => "Parse the content of this page. Overrides {$p}page",