35use Wikimedia\Bcp47Code\Bcp47Code;
58 $this->revisionStore = $revisionStore;
59 $this->slotRoleRegistry = $slotRoleRegistry;
60 $this->languageFactory = $languageFactory;
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.' );
169 $parserOptions->
setOption(
'enableLimitReport',
false );
171 $slotRoleHandler = $this->slotRoleRegistry->getRoleHandler( SlotRecord::MAIN );
172 if ( $pageLanguageOverride ) {
173 $pageLanguage = $this->languageFactory->getLanguage( $pageLanguageOverride );
175 $pageLanguage = $title->getPageLanguage();
178 $pageConfig =
new PageConfig(
184 $pageLanguage->getDir()
187 if ( $ensureAccessibleContent ) {
188 if ( $revisionRecord ===
null ) {
190 throw new RevisionAccessException(
'The specified revision does not exist.' );
195 $pageConfig->getRevisionContent()->getContent( SlotRecord::MAIN );
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Logs a warning that a deprecated feature was used.
Helper class used by MediaWiki to create Parsoid PageConfig objects.
__construct(RevisionStore $revisionStore, SlotRoleRegistry $slotRoleRegistry, LanguageFactory $languageFactory)
create(PageIdentity $pageId, ?UserIdentity $user=null, $revision=null, ?string $unused=null, ?Bcp47Code $pageLanguageOverride=null, bool $ensureAccessibleContent=false)
Create a new PageConfig.
Page-level configuration interface for Parsoid.
Set options of the Parser.
setOption( $name, $value)
Set an option, generically.
static newFromUser( $user)
Get a ParserOptions object from a given user.
Interface for database access objects.
Interface for objects (potentially) representing an editable wiki page.