if ( $params['onlypst'] ) {
// Build a result and bail out
$result_array = [];
- if ( $this->contentIsDeleted ) {
- $result_array['textdeleted'] = true;
- }
- if ( $this->contentIsSuppressed ) {
- $result_array['textsuppressed'] = true;
- }
$result_array['text'] = $this->pstContent->serialize( $format );
$result_array[ApiResult::META_BC_SUBELEMENTS][] = 'text';
if ( isset( $prop['wikitext'] ) ) {
$outputPage = new OutputPage( $context );
$outputPage->addParserOutputMetadata( $p_result );
+ if ( $this->content ) {
+ $outputPage->addContentOverride( $titleObj, $this->content );
+ }
$context->setOutput( $outputPage );
if ( $skin ) {
// Based on OutputPage::headElement()
$skin->setupSkinUserCss( $outputPage );
// Based on OutputPage::output()
- foreach ( $skin->getDefaultModules() as $group ) {
- $outputPage->addModules( $group );
- }
+ $outputPage->loadSkinModules( $skin );
}
+
+ Hooks::run( 'ApiParseMakeOutputPage', [ $this, $outputPage ] );
}
if ( !is_null( $oldid ) ) {
}
if ( isset( $prop['displaytitle'] ) ) {
- $result_array['displaytitle'] = $p_result->getDisplayTitle() ?:
- $titleObj->getPrefixedText();
+ $result_array['displaytitle'] = $p_result->getDisplayTitle() !== false
+ ? $p_result->getDisplayTitle() : $titleObj->getPrefixedText();
}
if ( isset( $prop['headitems'] ) ) {
}
$wgParser->startExternalParse( $titleObj, $popts, Parser::OT_PREPROCESS );
- $dom = $wgParser->preprocessToDom( $this->content->getNativeData() );
- if ( is_callable( [ $dom, 'saveXML' ] ) ) {
- $xml = $dom->saveXML();
- } else {
- $xml = $dom->__toString();
- }
+ $xml = $wgParser->preprocessToDom( $this->content->getNativeData() )->__toString();
$result_array['parsetree'] = $xml;
$result_array[ApiResult::META_BC_SUBELEMENTS][] = 'parsetree';
}
} else {
$this->content = $page->getContent( Revision::FOR_THIS_USER, $this->getUser() );
if ( !$this->content ) {
- $this->dieWithError( [ 'apierror-missingcontent-pageid', $pageId ] );
+ $this->dieWithError( [ 'apierror-missingcontent-pageid', $page->getId() ] );
}
}
$this->contentIsDeleted = $isDeleted;
$pout = $page->getParserOutput( $popts, $revId, $suppressCache );
}
if ( !$pout ) {
- $this->dieWithError( [ 'apierror-nosuchrevid', $revId ?: $page->getLatest() ] );
+ $this->dieWithError( [ 'apierror-nosuchrevid', $revId ?: $page->getLatest() ] ); // @codeCoverageIgnore
}
return $pout;