X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fapi%2FApiParse.php;h=2e7db78327135c0243e1fe81627fe0e0288d59e5;hb=b499692d01ff5372a20c6c727de57eb99a1b711c;hp=5e4639d6f56ae3ee27a02a68fabb5547ca5190e6;hpb=7787e4ff4554637c1422d3f760f5da491656c835;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiParse.php b/includes/api/ApiParse.php index 5e4639d6f5..2e7db78327 100644 --- a/includes/api/ApiParse.php +++ b/includes/api/ApiParse.php @@ -21,6 +21,7 @@ */ use MediaWiki\MediaWikiServices; +use MediaWiki\Revision\RevisionRecord; /** * @ingroup API @@ -83,7 +84,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; @@ -105,7 +106,7 @@ class ApiParse extends ApiBase { } $this->checkTitleUserPermissions( $rev->getTitle(), 'read' ); - if ( !$rev->userCan( Revision::DELETED_TEXT, $this->getUser() ) ) { + if ( !$rev->userCan( RevisionRecord::DELETED_TEXT, $this->getUser() ) ) { $this->dieWithError( [ 'apierror-permissiondenied', $this->msg( 'action-deletedtext' ) ] ); @@ -488,8 +489,10 @@ 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 ); + // @phan-suppress-next-line PhanUndeclaredMethod + $xml = $parser->preprocessToDom( $this->content->getText() )->__toString(); $result_array['parsetree'] = $xml; $result_array[ApiResult::META_BC_SUBELEMENTS][] = 'parsetree'; } @@ -561,23 +564,23 @@ class ApiParse extends ApiBase { WikiPage $page, $popts, $suppressCache, $pageId, $rev, $getContent ) { $revId = $rev ? $rev->getId() : null; - $isDeleted = $rev && $rev->isDeleted( Revision::DELETED_TEXT ); + $isDeleted = $rev && $rev->isDeleted( RevisionRecord::DELETED_TEXT ); if ( $getContent || $this->section !== false || $isDeleted ) { if ( $rev ) { - $this->content = $rev->getContent( Revision::FOR_THIS_USER, $this->getUser() ); + $this->content = $rev->getContent( RevisionRecord::FOR_THIS_USER, $this->getUser() ); if ( !$this->content ) { $this->dieWithError( [ 'apierror-missingcontent-revid', $revId ] ); } } else { - $this->content = $page->getContent( Revision::FOR_THIS_USER, $this->getUser() ); + $this->content = $page->getContent( RevisionRecord::FOR_THIS_USER, $this->getUser() ); if ( !$this->content ) { $this->dieWithError( [ 'apierror-missingcontent-pageid', $page->getId() ] ); } } $this->contentIsDeleted = $isDeleted; $this->contentIsSuppressed = $rev && - $rev->isDeleted( Revision::DELETED_TEXT | Revision::DELETED_RESTRICTED ); + $rev->isDeleted( RevisionRecord::DELETED_TEXT | RevisionRecord::DELETED_RESTRICTED ); } if ( $this->section !== false ) { @@ -631,7 +634,6 @@ class ApiParse extends ApiBase { * @return Content|bool */ private function formatSummary( $title, $params ) { - global $wgParser; $summary = $params['summary'] ?? ''; $sectionTitle = $params['sectiontitle'] ?? ''; @@ -641,8 +643,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' );