X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Fapi%2FApiParse.php;h=099d278f0cafdaae660d648dbe9aaf695340216a;hp=ec015da7129edb7d6c598ea4d86b3b388dafd03e;hb=54d50ef3921dc9f30dc4d863ddc471dc564998e9;hpb=3844fd9d639ed67cd3519eab2d7db440100cdd26 diff --git a/includes/api/ApiParse.php b/includes/api/ApiParse.php index ec015da712..099d278f0c 100644 --- a/includes/api/ApiParse.php +++ b/includes/api/ApiParse.php @@ -1,7 +1,5 @@ @gmail.com" * * This program is free software; you can redistribute it and/or modify @@ -245,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'] ) ) { @@ -346,6 +338,8 @@ class ApiParse extends ApiBase { $result_array['text'] = $p_result->getText( [ 'allowTOC' => !$params['disabletoc'], 'enableSectionEditLinks' => !$params['disableeditsection'], + 'unwrap' => $params['wrapoutputclass'] === '', + 'deduplicateStyles' => !$params['disablestylededuplication'], ] ); $result_array[ApiResult::META_BC_SUBELEMENTS][] = 'text'; } @@ -400,8 +394,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 +484,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'; } @@ -536,13 +525,12 @@ class ApiParse extends ApiBase { $popts->enableLimitReport( !$params['disablepp'] && !$params['disablelimitreport'] ); $popts->setIsPreview( $params['preview'] || $params['sectionpreview'] ); $popts->setIsSectionPreview( $params['sectionpreview'] ); - $popts->setEditSection( !$params['disableeditsection'] ); if ( $params['disabletidy'] ) { $popts->setTidy( false ); } - $popts->setWrapOutputClass( - $params['wrapoutputclass'] === '' ? false : $params['wrapoutputclass'] - ); + if ( $params['wrapoutputclass'] !== '' ) { + $popts->setWrapOutputClass( $params['wrapoutputclass'] ); + } $reset = null; $suppressCache = false; @@ -579,7 +567,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; @@ -603,7 +591,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; @@ -878,6 +866,7 @@ class ApiParse extends ApiBase { 'disablelimitreport' => false, 'disableeditsection' => false, 'disabletidy' => false, + 'disablestylededuplication' => false, 'generatexml' => [ ApiBase::PARAM_DFLT => false, ApiBase::PARAM_HELP_MSG => [