X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fapi%2FApiParse.php;h=3a604715bcb0f3e912b3f6f6ca6e4986537c6b98;hb=e599ca39822c27a18053e10cb54aa45b461730f5;hp=cbd62a97df36399f54ce40072f733eaa1f2663ce;hpb=77e3624caba072521fbc1826af2d47f9b29f4032;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiParse.php b/includes/api/ApiParse.php index cbd62a97df..3a604715bc 100644 --- a/includes/api/ApiParse.php +++ b/includes/api/ApiParse.php @@ -243,12 +243,6 @@ class ApiParse extends ApiBase { 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'] ) ) { @@ -320,16 +314,19 @@ class ApiParse extends ApiBase { $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 ) ) { @@ -400,8 +397,8 @@ class ApiParse extends ApiBase { } 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'] ) ) { @@ -490,12 +487,7 @@ class ApiParse extends ApiBase { } $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'; } @@ -578,7 +570,7 @@ class ApiParse extends ApiBase { } 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; @@ -602,7 +594,7 @@ class ApiParse extends ApiBase { $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; @@ -705,7 +697,7 @@ class ApiParse extends ApiBase { $hiddencats[$row->page_title] = isset( $row->pp_propname ); } - $linkCache = LinkCache::singleton(); + $linkCache = MediaWikiServices::getInstance()->getLinkCache(); foreach ( $links as $link => $sortkey ) { $entry = [];