87 ?
string $unused =
null,
88 ?Bcp47Code $pageLanguageOverride =
null,
89 bool $ensureAccessibleContent =
false
91 $title =
Title::newFromPageIdentity( $pageId );
93 if ( $unused !==
null ) {
94 wfDeprecated( __METHOD__ .
' with non-null 4th arg',
'1.40' );
97 if ( $revision ===
null ) {
105 $revisionRecord = $this->revisionStore->getKnownCurrentRevision(
110 } elseif ( !is_int( $revision ) ) {
111 $revisionRecord = $revision;
113 if ( $revision === 0 ) {
119 throw new \UnexpectedValueException(
120 "Got revision ID 0 indicating unsaved content. " .
121 "Unsaved content must be provided as a RevisionRecord object."
128 $revisionRecord = $this->revisionStore->getRevisionById( $revision );
129 if ( $revisionRecord ===
null ) {
134 $revisionRecord = $this->revisionStore->getRevisionById(
135 $revision, IDBAccessObject::READ_LATEST
137 $success = ( $revisionRecord !== null ) ?
'success' :
'failure';
138 LoggerFactory::getInstance(
'Parsoid' )->error(
139 "Retried revision fetch after failure: {$success}", [
141 'title' => $title->getPrefixedText(),
145 if ( $revisionRecord ===
null ) {
146 throw new RevisionAccessException(
"Can't find revision {$revision}" );
153 $revisionRecord !==
null &&
154 !$revisionRecord->audienceCan(
155 RevisionRecord::DELETED_TEXT, RevisionRecord::FOR_PUBLIC
158 throw new SuppressedDataException(
'Not an available content version.' );
164 : ParserOptions::newFromAnon();
169 $parserOptions->setOption(
'enableLimitReport',
false );
171 $slotRoleHandler = $this->slotRoleRegistry->getRoleHandler( SlotRecord::MAIN );
172 if ( $pageLanguageOverride ) {
173 $pageLanguage = $this->languageFactory->getLanguage( $pageLanguageOverride );
174 $parserOptions->setTargetLanguage( $pageLanguage );
176 $pageLanguage = $title->getPageLanguage();
179 $pageConfig =
new PageConfig(
185 $pageLanguage->getDir()
188 if ( $ensureAccessibleContent ) {
189 if ( $revisionRecord ===
null ) {
191 throw new RevisionAccessException(
'The specified revision does not exist.' );
196 $pageConfig->getRevisionContent()->getContent( SlotRecord::MAIN );