26 use InvalidArgumentException;
31 use Psr\Log\LoggerInterface;
32 use Psr\Log\NullLogger;
75 $this->roleRegistery = $roleRegistry;
78 $this->saveParseLogger =
new NullLogger();
114 if ( $rev->
getWikiId() !== $this->dbDomain ) {
115 throw new InvalidArgumentException(
'Mismatching wiki ID ' . $rev->
getWikiId() );
118 $audience = $hints[
'audience']
129 $forPerformer ? $forPerformer->getUser() :
'canonical'
133 $usePrimary = $hints[
'use-master'] ??
false;
135 $dbIndex = $usePrimary
139 $options->setSpeculativeRevIdCallback(
function () use ( $dbIndex ) {
142 $options->setSpeculativePageIdCallback(
function () use ( $dbIndex ) {
156 $this->contentRenderer,
166 if ( isset( $hints[
'known-revision-output'] ) ) {
167 $renderedRevision->setRevisionParserOutput( $hints[
'known-revision-output'] );
170 return $renderedRevision;
178 $db = $this->loadBalancer->getConnectionRef( $dbIndex, [], $this->dbDomain, $flags );
180 return 1 + (int)$db->selectField(
193 $db = $this->loadBalancer->getConnectionRef( $dbIndex, [], $this->dbDomain, $flags );
195 return 1 + (int)$db->selectField(
215 $slots = $revision->getSlots()->getSlots();
217 $withHtml = $hints[
'generate-html'] ??
true;
233 $options->registerWatcher( [ $combinedOutput,
'recordOption' ] );
235 foreach ( $slots as $role => $slot ) {
237 $slotOutput[$role] = $out;
240 $combinedOutput->mergeInternalMetaDataFrom( $out );
241 $combinedOutput->mergeTrackingMetaDataFrom( $out );
248 foreach ( $slotOutput as $role => $out ) {
249 $roleHandler = $this->roleRegistery->getRoleHandler( $role );
252 $layout = $roleHandler->getOutputLayoutHints();
253 $display = $layout[
'display'] ??
'section';
255 if ( $display ===
'none' ) {
265 $html .=
Html::rawElement(
'h1', [
'class' =>
'mw-slot-header' ], $headText );
270 $html .= $out->getRawText();
271 $combinedOutput->mergeHtmlMetaDataFrom( $out );
274 $combinedOutput->setText( $html );
277 $options->registerWatcher(
null );
278 return $combinedOutput;
This class is a collection of static functions that serve two purposes:
static element( $element, $attribs=[], $contents='')
Identical to rawElement(), but HTML-escapes $contents (like Xml::element()).
static rawElement( $element, $attribs=[], $contents='')
Returns an HTML element in a string.
A service to render content.
Set options of the Parser.
static newCanonical( $context, $userLang=null)
Creates a "canonical" ParserOptions object.