90 ?
string $unused =
null,
91 ?Bcp47Code $pageLanguageOverride =
null,
92 ?array $parsoidSettings =
null
95 '@phan-var Title $title';
97 if ( !empty( $parsoidSettings[
'debugApi'] ) ) {
98 if ( $revision ===
null ) {
99 throw new \InvalidArgumentException(
100 "Revision not provided. Cannot lookup revision via debug API." );
103 $content = $revision->getContent( SlotRecord::MAIN );
106 return ApiPageConfig::fromSettings( $parsoidSettings, [
107 "title" =>
$title->getPrefixedText(),
108 "pageContent" => $wtContent,
109 "pageLanguage" => $pageLanguageOverride, # ?Bcp47Code
110 "revid" => $revision->getId(),
114 throw new \UnexpectedValueException(
115 "Non-wikitext content models not supported by debug API" );
119 if ( $revision ===
null ) {
127 $revisionRecord = $this->revisionStore->getKnownCurrentRevision(
132 } elseif ( !is_int( $revision ) ) {
133 $revisionRecord = $revision;
135 if ( $revision === 0 ) {
141 throw new \UnexpectedValueException(
142 "Got revision ID 0 indicating unsaved content. " .
143 "Unsaved content must be provided as a RevisionRecord object."
150 $revisionRecord = $this->revisionStore->getRevisionById( $revision );
151 if ( $revisionRecord ===
null ) {
156 $revisionRecord = $this->revisionStore->getRevisionById(
157 $revision, RevisionStore::READ_LATEST
159 $success = ( $revisionRecord !== null ) ?
'success' :
'failure';
160 LoggerFactory::getInstance(
'Parsoid' )->error(
161 "Retried revision fetch after failure: {$success}", [
163 'title' =>
$title->getPrefixedText(),
167 if ( $revisionRecord ===
null ) {
168 throw new RevisionAccessException(
"Can't find revision {$revision}" );
175 $revisionRecord !==
null &&
176 !$revisionRecord->audienceCan(
177 RevisionRecord::DELETED_TEXT, RevisionRecord::FOR_PUBLIC
180 throw new RevisionAccessException(
'Not an available content version.' );
191 $parserOptions->
setOption(
'enableLimitReport',
false );
193 $slotRoleHandler = $this->slotRoleRegistry->getRoleHandler( SlotRecord::MAIN );
194 if ( $pageLanguageOverride ) {
195 $pageLanguage = $this->languageFactory->getLanguage( $pageLanguageOverride );
197 $pageLanguage =
$title->getPageLanguage();
199 return new PageConfig(
205 $pageLanguage->getDir()