MediaWiki REL1_34
MediaWiki\Revision\RenderedRevision Class Reference

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

Inheritance diagram for MediaWiki\Revision\RenderedRevision:
Collaboration diagram for MediaWiki\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().
 
 setSaveParseLogger (LoggerInterface $saveParseLogger)
 
 updateRevision (RevisionRecord $rev)
 Updates the RevisionRecord after the revision has been saved.
 

Private Member Functions

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

Private Attributes

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

MediaWiki\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 MediaWiki\Revision\RenderedRevision\$audience, MediaWiki\Revision\RenderedRevision\$combineOutput, MediaWiki\Revision\RenderedRevision\$forUser, MediaWiki\Revision\RenderedRevision\$options, MediaWiki\Revision\RenderedRevision\$title, MediaWiki\Revision\RevisionRecord\FOR_THIS_USER, and MediaWiki\Revision\RenderedRevision\setRevisionInternal().

Member Function Documentation

◆ getOptions()

MediaWiki\Revision\RenderedRevision::getOptions ( )

◆ getRevision()

MediaWiki\Revision\RenderedRevision::getRevision ( )
Returns
RevisionRecord

Definition at line 151 of file RenderedRevision.php.

References MediaWiki\Revision\RenderedRevision\$revision.

Referenced by MediaWiki\Revision\RevisionRenderer\combineSlotOutput().

◆ getRevisionParserOutput()

MediaWiki\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. -param array{generate-html?:bool} $hints
Returns
ParserOutput

Definition at line 192 of file RenderedRevision.php.

References MediaWiki\Revision\RenderedRevision\$revisionOutput.

◆ getSlotParserOutput()

MediaWiki\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. -param array{generate-html?:bool} $hints
Exceptions
SuppressedDataExceptionif the content is not accessible for the audience specified in the constructor.
Returns
ParserOutput

Implements MediaWiki\Revision\SlotRenderingProvider.

Definition at line 222 of file RenderedRevision.php.

References $content, and MediaWiki\Revision\RenderedRevision\getSlotParserOutputUncached().

Referenced by MediaWiki\Revision\RevisionRenderer\combineSlotOutput().

◆ getSlotParserOutputUncached()

MediaWiki\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 262 of file RenderedRevision.php.

References $content.

Referenced by MediaWiki\Revision\RenderedRevision\getSlotParserOutput().

◆ isContentDeleted()

MediaWiki\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 MediaWiki\Revision\RevisionRecord\DELETED_TEXT.

◆ outputVariesOnRevisionMetaData()

MediaWiki\Revision\RenderedRevision::outputVariesOnRevisionMetaData ( ParserOutput $out,
$actualPageId,
$actualRevId,
$actualRevTimestamp )
private
Parameters
ParserOutput$out
int | bool$actualPageIdThe actual page id, to check the used speculative page ID against; false, to not purge on vary-page-id; true, to purge on vary-page-id unconditionally.
int | bool$actualRevIdThe actual rev id, to check the used speculative rev ID against,; false, to not purge on vary-revision-id; true, to purge on vary-revision-id unconditionally.
string | bool$actualRevTimestampThe actual rev timestamp, to check against the parser output revision timestamp; false, to not purge on vary-revision-timestamp; true, to purge on vary-revision-timestamp unconditionally.
Returns
bool

Definition at line 411 of file RenderedRevision.php.

References $context, MediaWiki\Revision\RenderedRevision\$saveParseLogger, ParserOutput\getFlag(), ParserOutput\getRevisionTimestampUsed(), ParserOutput\getRevisionUsedSha1Base36(), ParserOutput\getSpeculativePageIdUsed(), and ParserOutput\getSpeculativeRevIdUsed().

Referenced by MediaWiki\Revision\RenderedRevision\pruneRevisionSensitiveOutput().

◆ pruneRevisionSensitiveOutput()

MediaWiki\Revision\RenderedRevision::pruneRevisionSensitiveOutput ( $actualPageId,
$actualRevId,
$actualRevTimestamp )
private

Prune any output that depends on the revision ID.

Parameters
int | bool$actualPageIdThe actual page id, to check the used speculative page ID against; false, to not purge on vary-page-id; true, to purge on vary-page-id unconditionally.
int | bool$actualRevIdThe actual rev id, to check the used speculative rev ID against,; false, to not purge on vary-revision-id; true, to purge on vary-revision-id unconditionally.
string | bool$actualRevTimestampThe actual rev timestamp, to check against the parser output revision timestamp; false, to not purge on vary-revision-timestamp; true, to purge on vary-revision-timestamp unconditionally.

Definition at line 316 of file RenderedRevision.php.

References MediaWiki\Revision\RenderedRevision\outputVariesOnRevisionMetaData().

Referenced by MediaWiki\Revision\RenderedRevision\updateRevision().

◆ setRevisionInternal()

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

◆ setRevisionParserOutput()

MediaWiki\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 MediaWiki\Revision\SlotRecord\MAIN.

◆ setSaveParseLogger()

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

Definition at line 137 of file RenderedRevision.php.

References MediaWiki\Revision\RenderedRevision\$saveParseLogger.

Referenced by MediaWiki\Revision\RevisionRenderer\getRenderedRevision().

◆ updateRevision()

MediaWiki\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 280 of file RenderedRevision.php.

References MediaWiki\Revision\RevisionRecord\getId(), MediaWiki\Revision\RevisionRecord\getSlots(), MediaWiki\Revision\RenderedRevision\pruneRevisionSensitiveOutput(), and MediaWiki\Revision\RenderedRevision\setRevisionInternal().

Member Data Documentation

◆ $audience

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

Audience to check when accessing content.

Definition at line 62 of file RenderedRevision.php.

Referenced by MediaWiki\Revision\RenderedRevision\__construct().

◆ $combineOutput

callable MediaWiki\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 MediaWiki\Revision\RenderedRevision\__construct().

◆ $forUser

User null MediaWiki\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 MediaWiki\Revision\RenderedRevision\__construct().

◆ $options

ParserOptions MediaWiki\Revision\RenderedRevision::$options
private

◆ $revision

RevisionRecord MediaWiki\Revision\RenderedRevision::$revision
private

◆ $revisionOutput

ParserOutput null MediaWiki\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 MediaWiki\Revision\RenderedRevision\getRevisionParserOutput().

◆ $saveParseLogger

LoggerInterface MediaWiki\Revision\RenderedRevision::$saveParseLogger
private

◆ $slotsOutput

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

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

Definition at line 79 of file RenderedRevision.php.

◆ $title

Title MediaWiki\Revision\RenderedRevision::$title
private

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