From 83a51c0e7129084c2db3d53e26d46f606c0e25a0 Mon Sep 17 00:00:00 2001 From: Brad Jorsch Date: Thu, 9 Jan 2014 11:53:08 -0500 Subject: [PATCH] API: Allow special pages for action=parse&title= 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 | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/includes/api/ApiParse.php b/includes/api/ApiParse.php index a323aad954..464fde66c0 100644 --- a/includes/api/ApiParse.php +++ b/includes/api/ApiParse.php @@ -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" ), ) ); } -- 2.20.1