MediaWiki  1.33.0
Revision\RenderedRevision Class Reference

RenderedRevision represents the rendered representation of a revision. More...

Inheritance diagram for Revision\RenderedRevision:
Collaboration diagram for Revision\RenderedRevision:

Public Member Functions

 __construct (Title $title, RevisionRecord $revision, ParserOptions $options, callable $combineOutput, $audience=RevisionRecord::FOR_PUBLIC, User $forUser=null)
 
 getOptions ()
 
 getRevision ()
 
 getRevisionParserOutput (array $hints=[])
 
 getSlotParserOutput ( $role, array $hints=[])
 
 isContentDeleted ()
 
 setRevisionParserOutput (ParserOutput $output)
 Sets a ParserOutput to be returned by getRevisionParserOutput(). More...
 
 setSaveParseLogger (LoggerInterface $saveParseLogger)
 
 updateRevision (RevisionRecord $rev)
 Updates the RevisionRecord after the revision has been saved. More...
 

Private Member Functions

 getSlotParserOutputUncached (Content $content, $withHtml)
 
 outputVariesOnRevisionMetaData (ParserOutput $out, $actualRevId)
 
 pruneRevisionSensitiveOutput ( $actualRevId)
 Prune any output that depends on the revision ID. More...
 
 setRevisionInternal (RevisionRecord $revision)
 

Private Attributes

int $audience = RevisionRecord::FOR_PUBLIC
 Audience to check when accessing content. More...
 
callable $combineOutput
 Callback for combining slot output into revision output. More...
 
User null $forUser = null
 The user to use for audience checks during content access. More...
 
ParserOptions $options
 
RevisionRecord $revision
 
ParserOutput null $revisionOutput = null
 The combined ParserOutput for the revision, initialized lazily by getRevisionParserOutput(). More...
 
LoggerInterface $saveParseLogger
 For profiling ParserOutput re-use. More...
 
ParserOutput[] $slotsOutput = []
 The ParserOutput for each slot, initialized lazily by getSlotParserOutput(). More...
 
Title $title
 

Detailed Description

RenderedRevision represents the rendered representation of a revision.

It acts as a lazy provider of ParserOutput objects for the revision's individual slots, as well as a combined ParserOutput of all slots.

Since
1.32

Definition at line 44 of file RenderedRevision.php.

Constructor & Destructor Documentation

◆ __construct()

Revision\RenderedRevision::__construct ( Title  $title,
RevisionRecord  $revision,
ParserOptions  $options,
callable  $combineOutput,
  $audience = RevisionRecord::FOR_PUBLIC,
User  $forUser = null 
)
Note
Application logic should not instantiate RenderedRevision instances directly, but should use a RevisionRenderer instead.
Parameters
Title$title
RevisionRecord$revisionThe revision to render. The content for rendering will be taken from this RevisionRecord. However, if the RevisionRecord is not complete according isReadyForInsertion(), but a revision ID is known, the parser may load the revision from the database if it needs revision meta data to handle magic words like {{REVISIONUSER}}.
ParserOptions$options
callable$combineOutputCallback for combining slot output into revision output. Signature: function ( RenderedRevision $this ): ParserOutput.
int$audienceUse RevisionRecord::FOR_PUBLIC, FOR_THIS_USER, or RAW.
User | null$forUserRequired if $audience is FOR_THIS_USER.

Definition at line 108 of file RenderedRevision.php.

References Revision\RenderedRevision\$audience, Revision\RenderedRevision\$combineOutput, Revision\RenderedRevision\$forUser, Revision\RenderedRevision\$options, Revision\RenderedRevision\$title, Revision\RevisionRecord\FOR_THIS_USER, options(), Revision\RenderedRevision\setRevisionInternal(), and title.

Member Function Documentation

◆ getOptions()

Revision\RenderedRevision::getOptions ( )

◆ getRevision()

◆ getRevisionParserOutput()

Revision\RenderedRevision::getRevisionParserOutput ( array  $hints = [])
Parameters
array$hintsHints given as an associative array. Known keys:
  • 'generate-html' => bool: Whether the caller is interested in output HTML (as opposed to just meta-data). Default is to generate HTML.
Returns
ParserOutput

Definition at line 191 of file RenderedRevision.php.

References $output, and Revision\RenderedRevision\$revisionOutput.

◆ getSlotParserOutput()

Revision\RenderedRevision::getSlotParserOutput (   $role,
array  $hints = [] 
)
Parameters
string$role
array$hintsHints given as an associative array. Known keys:
  • 'generate-html' => bool: Whether the caller is interested in output HTML (as opposed to just meta-data). Default is to generate HTML.
Exceptions
SuppressedDataExceptionif the content is not accessible for the audience specified in the constructor.
Returns
ParserOutput

Implements Revision\SlotRenderingProvider.

Definition at line 220 of file RenderedRevision.php.

References $content, $output, Revision\RenderedRevision\getSlotParserOutputUncached(), options(), and revision.

Referenced by MediaWiki\Tests\Revision\RenderedRevisionTest\combineOutput(), and Revision\RevisionRenderer\combineSlotOutput().

◆ getSlotParserOutputUncached()

Revision\RenderedRevision::getSlotParserOutputUncached ( Content  $content,
  $withHtml 
)
private
Note
This method exist to make duplicate parses easier to see during profiling
Parameters
Content$content
bool$withHtml
Returns
ParserOutput

Definition at line 260 of file RenderedRevision.php.

References $content, Revision\RenderedRevision\$options, revision, and title.

Referenced by Revision\RenderedRevision\getSlotParserOutput().

◆ isContentDeleted()

Revision\RenderedRevision::isContentDeleted ( )
Returns
bool Whether the revision's content has been hidden from unprivileged users.

Definition at line 144 of file RenderedRevision.php.

References Revision\RevisionRecord\DELETED_TEXT, and revision.

◆ outputVariesOnRevisionMetaData()

Revision\RenderedRevision::outputVariesOnRevisionMetaData ( ParserOutput  $out,
  $actualRevId 
)
private
Parameters
ParserOutput$out
int | bool$actualRevIdThe actual rev id, to check the used speculative rev ID against, or false to not purge on vary-revision-id, or true to purge on vary-revision-id unconditionally.
Returns
bool

Definition at line 379 of file RenderedRevision.php.

References $out, and wfDebug().

Referenced by Revision\RenderedRevision\pruneRevisionSensitiveOutput().

◆ pruneRevisionSensitiveOutput()

Revision\RenderedRevision::pruneRevisionSensitiveOutput (   $actualRevId)
private

Prune any output that depends on the revision ID.

Parameters
int | bool$actualRevIdThe actual rev id, to check the used speculative rev ID against, or false to not purge on vary-revision-id, or true to purge on vary-revision-id unconditionally.

Definition at line 304 of file RenderedRevision.php.

References $output, as, and Revision\RenderedRevision\outputVariesOnRevisionMetaData().

Referenced by Revision\RenderedRevision\updateRevision().

◆ setRevisionInternal()

Revision\RenderedRevision::setRevisionInternal ( RevisionRecord  $revision)
private

◆ setRevisionParserOutput()

Revision\RenderedRevision::setRevisionParserOutput ( ParserOutput  $output)

Sets a ParserOutput to be returned by getRevisionParserOutput().

Note
For internal use by RevisionRenderer only! This method may be modified or removed without notice per the deprecation policy.

Definition at line 172 of file RenderedRevision.php.

References $output, Revision\SlotRecord\MAIN, and revision.

◆ setSaveParseLogger()

Revision\RenderedRevision::setSaveParseLogger ( LoggerInterface  $saveParseLogger)
Parameters
LoggerInterface$saveParseLogger

Definition at line 137 of file RenderedRevision.php.

References Revision\RenderedRevision\$saveParseLogger.

Referenced by Revision\RevisionRenderer\getRenderedRevision().

◆ updateRevision()

Revision\RenderedRevision::updateRevision ( RevisionRecord  $rev)

Updates the RevisionRecord after the revision has been saved.

This can be used to discard and cached ParserOutput so parser functions like {{REVISIONTIMESTAMP}} or {{REVISIONID}} are re-evaluated.

Note
There should be no need to call this for null-edits.
Parameters
RevisionRecord$rev

Definition at line 278 of file RenderedRevision.php.

References $rev, Revision\RevisionRecord\getId(), Revision\RevisionRecord\getSlots(), Revision\RenderedRevision\pruneRevisionSensitiveOutput(), revision, and Revision\RenderedRevision\setRevisionInternal().

Member Data Documentation

◆ $audience

int Revision\RenderedRevision::$audience = RevisionRecord::FOR_PUBLIC
private

Audience to check when accessing content.

Definition at line 62 of file RenderedRevision.php.

Referenced by Revision\RenderedRevision\__construct().

◆ $combineOutput

callable Revision\RenderedRevision::$combineOutput
private

Callback for combining slot output into revision output.

Signature: function ( RenderedRevision $this ): ParserOutput.

Definition at line 85 of file RenderedRevision.php.

Referenced by Revision\RenderedRevision\__construct().

◆ $forUser

User null Revision\RenderedRevision::$forUser = null
private

The user to use for audience checks during content access.

Definition at line 67 of file RenderedRevision.php.

Referenced by Revision\RenderedRevision\__construct().

◆ $options

◆ $revision

RevisionRecord Revision\RenderedRevision::$revision
private

◆ $revisionOutput

ParserOutput null Revision\RenderedRevision::$revisionOutput = null
private

The combined ParserOutput for the revision, initialized lazily by getRevisionParserOutput().

Definition at line 73 of file RenderedRevision.php.

Referenced by Revision\RenderedRevision\getRevisionParserOutput().

◆ $saveParseLogger

LoggerInterface Revision\RenderedRevision::$saveParseLogger
private

For profiling ParserOutput re-use.

Definition at line 90 of file RenderedRevision.php.

Referenced by Revision\RenderedRevision\setSaveParseLogger().

◆ $slotsOutput

ParserOutput [] Revision\RenderedRevision::$slotsOutput = []
private

The ParserOutput for each slot, initialized lazily by getSlotParserOutput().

Definition at line 79 of file RenderedRevision.php.

◆ $title

Title Revision\RenderedRevision::$title
private

The documentation for this class was generated from the following file: