}
// Should we save old revision parses to the parser cache?
- $p_result = $this->content->getParserOutput( $titleObj, $popts );
+ $p_result = $this->content->getParserOutput( $titleObj, $rev->getId(), $popts );
}
} else { // Not $oldid, but $pageid or $page
if ( $params['redirects'] ) {
$pageObj = $this->getTitleOrPageId( $pageParams, 'fromdb' );
$titleObj = $pageObj->getTitle();
+ if ( !$titleObj || !$titleObj->exists() ) {
+ $this->dieUsage( "The page you specified doesn't exist", 'missingtitle' );
+ }
$wgTitle = $titleObj;
if ( isset( $prop['revid'] ) ) {
$oldid = $pageObj->getLatest();
}
-
$popts = $pageObj->makeParserOptions( $this->getContext() );
$popts->enableLimitReport( !$params['disablepp'] );
// Potentially cached
- $p_result = $this->getParsedContent( $pageObj, $popts, $pageid,
+ $p_result = $this->getParsedContent( $pageObj, $popts, $pageid,
isset( $prop['wikitext'] ) ) ;
}
} else { // Not $oldid, $pageid, $page. Hence based on $text
if ( !$titleObj ) {
$this->dieUsageMsg( array( 'invalidtitle', $title ) );
}
+ if ( !$titleObj->canExist() ) {
+ $this->dieUsage( "Namespace doesn't allow actual pages", 'pagecannotexist' );
+ }
$wgTitle = $titleObj;
$pageObj = WikiPage::factory( $titleObj );
// Not cached (save or load)
if ( $params['pst'] ) {
- $p_result = $this->pstContent->getParserOutput( $titleObj, $popts );
+ $p_result = $this->pstContent->getParserOutput( $titleObj, null, $popts );
} else {
- $p_result = $this->content->getParserOutput( $titleObj, $popts );
+ $p_result = $this->content->getParserOutput( $titleObj, null, $popts );
}
}
private function getParsedContent( WikiPage $page, $popts, $pageId = null, $getWikitext = false ) {
$this->content = $page->getContent( Revision::RAW ); //XXX: really raw?
- if ( $this->section !== false ) {
+ if ( $this->section !== false && $this->content !== null ) {
$this->content = $this->getSectionContent(
$this->content,
!is_null( $pageId ) ? 'page id ' . $pageId : $page->getTitle()->getText() );
// Not cached (save or load)
- return $this->content->getParserOutput( $page->getTitle(), $popts );
+ return $this->content->getParserOutput( $page->getTitle(), null, $popts );
} else {
// Try the parser cache first
// getParserOutput will save to Parser cache if able
'uselang' => 'Which language to parse the request in',
'section' => 'Only retrieve the content of this section number',
'disablepp' => 'Disable the PP Report from the parser output',
- 'generatexml' => 'Generate XML parse tree',
+ 'generatexml' => 'Generate XML parse tree (requires prop=wikitext)',
'contentformat' => 'Content serialization format used for the input text',
'contentmodel' => 'Content model of the new content',
);
array( 'invalidtitle', 'title' ),
array( 'code' => 'parseerror', 'info' => 'Failed to parse the given text.' ),
array( 'code' => 'notwikitext', 'info' => 'The requested operation is only supported on wikitext content.' ),
+ array( 'code' => 'pagecannotexist', 'info' => "Namespace doesn't allow actual pages" ),
) );
}