X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fapi%2FApiParse.php;h=84fff968d2ad9f23e16089208fd76f0760d7e002;hb=616525021b3691e30a980a42b837b7ad44ecfd09;hp=fc730e3ceb1cd33e61dc298d3e778fa3242766b4;hpb=7110e89e542f972bc148ece238829f00fb2e1053;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiParse.php b/includes/api/ApiParse.php index fc730e3ceb..84fff968d2 100644 --- a/includes/api/ApiParse.php +++ b/includes/api/ApiParse.php @@ -83,7 +83,7 @@ class ApiParse extends ApiBase { // The parser needs $wgTitle to be set, apparently the // $title parameter in Parser::parse isn't enough *sigh* // TODO: Does this still need $wgTitle? - global $wgParser, $wgTitle; + global $wgTitle; $redirValues = null; @@ -488,8 +488,9 @@ class ApiParse extends ApiBase { $this->dieWithError( 'apierror-parsetree-notwikitext', 'notwikitext' ); } - $wgParser->startExternalParse( $titleObj, $popts, Parser::OT_PREPROCESS ); - $xml = $wgParser->preprocessToDom( $this->content->getText() )->__toString(); + $parser = MediaWikiServices::getInstance()->getParser(); + $parser->startExternalParse( $titleObj, $popts, Parser::OT_PREPROCESS ); + $xml = $parser->preprocessToDom( $this->content->getText() )->__toString(); $result_array['parsetree'] = $xml; $result_array[ApiResult::META_BC_SUBELEMENTS][] = 'parsetree'; } @@ -631,9 +632,8 @@ class ApiParse extends ApiBase { * @return Content|bool */ private function formatSummary( $title, $params ) { - global $wgParser; - $summary = !is_null( $params['summary'] ) ? $params['summary'] : ''; - $sectionTitle = !is_null( $params['sectiontitle'] ) ? $params['sectiontitle'] : ''; + $summary = $params['summary'] ?? ''; + $sectionTitle = $params['sectiontitle'] ?? ''; if ( $this->section === 'new' && ( $sectionTitle === '' || $summary === '' ) ) { if ( $sectionTitle !== '' ) { @@ -641,8 +641,9 @@ class ApiParse extends ApiBase { } if ( $summary !== '' ) { $summary = wfMessage( 'newsectionsummary' ) - ->rawParams( $wgParser->stripSectionName( $summary ) ) - ->inContentLanguage()->text(); + ->rawParams( MediaWikiServices::getInstance()->getParser() + ->stripSectionName( $summary ) ) + ->inContentLanguage()->text(); } } return Linker::formatComment( $summary, $title, $this->section === 'new' );