2declare( strict_types = 1 );
23use Wikimedia\Bcp47Code\Bcp47Code;
65 ?
string $unused =
null,
66 ?Bcp47Code $pageLanguageOverride =
null,
67 bool $ensureAccessibleContent =
false
70 if ( $unused !==
null ) {
71 wfDeprecated( __METHOD__ .
' with non-null 4th arg',
'1.40' );
80 $parserOptions, $pageId, $revision,
81 $pageLanguageOverride, $ensureAccessibleContent
110 ?Bcp47Code $pageLanguageOverride =
null,
111 bool $ensureAccessibleContent =
false,
112 bool $checkAuthority =
false
114 $title =
Title::newFromPageIdentity( $pageId );
116 if ( $revision ===
null ) {
124 $revisionRecord = $this->revisionStore->getKnownLatestRevision(
129 } elseif ( !is_int( $revision ) ) {
130 $revisionRecord = $revision;
132 if ( $revision === 0 ) {
138 throw new \UnexpectedValueException(
139 "Got revision ID 0 indicating unsaved content. " .
140 "Unsaved content must be provided as a RevisionRecord object."
147 $revisionRecord = $this->revisionStore->getRevisionById( $revision );
148 if ( $revisionRecord ===
null ) {
153 $revisionRecord = $this->revisionStore->getRevisionById(
154 $revision, IDBAccessObject::READ_LATEST
156 $success = ( $revisionRecord !== null ) ?
'success' :
'failure';
157 LoggerFactory::getInstance(
'Parsoid' )->error(
158 "Retried revision fetch after failure: {$success}", [
160 'title' => $title->getPrefixedText(),
164 if ( $revisionRecord ===
null ) {
165 throw new RevisionAccessException(
"Can't find revision {$revision}" );
173 $revisionRecord !==
null &&
174 !$revisionRecord->audienceCan(
175 RevisionRecord::DELETED_TEXT, RevisionRecord::FOR_PUBLIC
178 throw new SuppressedDataException(
'Not an available content version.' );
184 $slotRoleHandler = $this->slotRoleRegistry->getRoleHandler( SlotRecord::MAIN );
186 if ( $pageLanguageOverride ) {
187 $pageLanguage = $this->languageFactory->getLanguage( $pageLanguageOverride );
190 $pageLanguage = $title->getPageLanguage();
193 $pageConfig =
new PageConfig(
199 $pageLanguage->getDir()
202 if ( $ensureAccessibleContent ) {
203 if ( $revisionRecord ===
null ) {
205 throw new RevisionAccessException(
'The specified revision does not exist.' );
210 $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.
createFromParserOptions(ParserOptions $parserOptions, PageIdentity $pageId, $revision=null, ?Bcp47Code $pageLanguageOverride=null, bool $ensureAccessibleContent=false, bool $checkAuthority=false)
Create a new PageConfig.
create(PageIdentity $pageId, ?UserIdentity $user=null, $revision=null, ?string $unused=null, ?Bcp47Code $pageLanguageOverride=null, bool $ensureAccessibleContent=false)
Create a new PageConfig.
__construct(private readonly RevisionStore $revisionStore, private readonly SlotRoleRegistry $slotRoleRegistry, private readonly LanguageFactory $languageFactory,)
Page-level configuration interface for Parsoid.
Interface for objects (potentially) representing an editable wiki page.