26use InvalidArgumentException;
30use Psr\Log\LoggerInterface;
31use Psr\Log\NullLogger;
70 $this->roleRegistery = $roleRegistry;
72 $this->saveParseLogger =
new NullLogger();
108 if ( $rev->
getWikiId() !== $this->dbDomain ) {
109 throw new InvalidArgumentException(
'Mismatching wiki ID ' . $rev->
getWikiId() );
112 $audience = $hints[
'audience']
122 $options = ParserOptions::newCanonical(
123 $forPerformer ? $forPerformer->getUser() :
'canonical'
127 $usePrimary = $hints[
'use-master'] ??
false;
129 $dbIndex = $usePrimary
133 $options->setSpeculativeRevIdCallback(
function () use ( $dbIndex ) {
136 $options->setSpeculativePageIdCallback(
function () use ( $dbIndex ) {
162 if ( isset( $hints[
'known-revision-output'] ) ) {
163 $renderedRevision->setRevisionParserOutput( $hints[
'known-revision-output'] );
166 return $renderedRevision;
172 $flags = ILoadBalancer::CONN_TRX_AUTOCOMMIT;
174 $db = $this->loadBalancer->getConnectionRef( $dbIndex, [], $this->dbDomain, $flags );
176 return 1 + (int)$db->selectField(
187 $flags = ILoadBalancer::CONN_TRX_AUTOCOMMIT;
189 $db = $this->loadBalancer->getConnectionRef( $dbIndex, [], $this->dbDomain, $flags );
191 return 1 + (int)$db->selectField(
211 $slots = $revision->getSlots()->getSlots();
213 $withHtml = $hints[
'generate-html'] ??
true;
229 $options->registerWatcher( [ $combinedOutput,
'recordOption' ] );
231 foreach ( $slots as $role => $slot ) {
233 $slotOutput[$role] = $out;
236 $combinedOutput->mergeInternalMetaDataFrom( $out );
237 $combinedOutput->mergeTrackingMetaDataFrom( $out );
244 foreach ( $slotOutput as $role => $out ) {
245 $roleHandler = $this->roleRegistery->getRoleHandler( $role );
248 $layout = $roleHandler->getOutputLayoutHints();
249 $display = $layout[
'display'] ??
'section';
251 if ( $display ===
'none' ) {
260 $headText = Html::element(
'mw:slotheader', [], $role );
261 $html .= Html::rawElement(
'h1', [
'class' =>
'mw-slot-header' ], $headText );
266 $html .= $out->getRawText();
267 $combinedOutput->mergeHtmlMetaDataFrom( $out );
270 $combinedOutput->setText( $html );
273 $options->registerWatcher(
null );
274 return $combinedOutput;
This class is a collection of static functions that serve two purposes:
Set options of the Parser.
Represents a title within MediaWiki.