API: Allow special pages for action=parse&title=
authorBrad Jorsch <bjorsch@wikimedia.org>
Thu, 9 Jan 2014 16:53:08 +0000 (11:53 -0500)
committerBrad Jorsch <bjorsch@wikimedia.org>
Thu, 9 Jan 2014 16:56:02 +0000 (11:56 -0500)
Iec98e472 had broken this. Use the same strategy as in
MediaWiki::initializeArticle to work around the problem.

Bug: 49477
Change-Id: Ib272b1f9395f6adade505ac7c6a24f9a4bff2779

includes/api/ApiParse.php

index a323aad..464fde6 100644 (file)
@@ -176,11 +176,14 @@ class ApiParse extends ApiBase {
                        if ( !$titleObj || $titleObj->isExternal() ) {
                                $this->dieUsageMsg( array( 'invalidtitle', $title ) );
                        }
-                       if ( !$titleObj->canExist() ) {
-                               $this->dieUsage( "Namespace doesn't allow actual pages", 'pagecannotexist' );
-                       }
                        $wgTitle = $titleObj;
-                       $pageObj = WikiPage::factory( $titleObj );
+                       if ( $titleObj->canExist() ) {
+                               $pageObj = WikiPage::factory( $titleObj );
+                       } else {
+                               // Do like MediaWiki::initializeArticle()
+                               $article = Article::newFromTitle( $titleObj, $this->getContext() );
+                               $pageObj = $article->getPage();
+                       }
 
                        $popts = $this->makeParserOptions( $pageObj, $params );
 
@@ -805,7 +808,6 @@ class ApiParse extends ApiBase {
                                'code' => 'notwikitext',
                                'info' => 'The requested operation is only supported on wikitext content.'
                        ),
-                       array( 'code' => 'pagecannotexist', 'info' => "Namespace doesn't allow actual pages" ),
                ) );
        }