*/
use MediaWiki\MediaWikiServices;
+use MediaWiki\Storage\RevisionRecord;
/**
* @ingroup API
// 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;
}
$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' ) ]
);
if ( isset( $prop['modules'] ) ) {
if ( $skin ) {
$result_array['modules'] = $outputPage->getModules();
- $result_array['modulescripts'] = $outputPage->getModuleScripts();
+ // Deprecated since 1.32 (T188689)
+ $result_array['modulescripts'] = [];
$result_array['modulestyles'] = $outputPage->getModuleStyles();
} else {
$result_array['modules'] = array_values( array_unique( $p_result->getModules() ) );
- $result_array['modulescripts'] = array_values( array_unique( $p_result->getModuleScripts() ) );
+ // Deprecated since 1.32 (T188689)
+ $result_array['modulescripts'] = [];
$result_array['modulestyles'] = array_values( array_unique( $p_result->getModuleStyles() ) );
}
}
$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';
}
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 ) {
* @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 !== '' ) {
}
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' );