MediaWiki  master
Page\ParserOutputAccess Class Reference

Service for getting rendered output of a given page. More...

Collaboration diagram for Page\ParserOutputAccess:

Public Member Functions

 __construct (ParserCache $primaryCache, RevisionOutputCache $secondaryCache, RevisionLookup $revisionLookup, RevisionRenderer $revisionRenderer, IBufferingStatsdDataFactory $statsDataFactory, ILBFactory $lbFactory, LoggerSpi $loggerSpi, WikiPageFactory $wikiPageFactory, TitleFormatter $titleFormatter)
 
 getCachedParserOutput (PageRecord $page, ParserOptions $parserOptions, ?RevisionRecord $revision=null, int $options=0)
 Returns the rendered output for the given page if it is present in the cache. More...
 
 getParserOutput (PageRecord $page, ParserOptions $parserOptions, ?RevisionRecord $revision=null, int $options=0)
 Returns the rendered output for the given page. More...
 

Private Member Functions

 checkPreconditions (PageRecord $page, ?RevisionRecord $revision=null, int $options=0)
 
 newPoolWorkArticleView (PageRecord $page, ParserOptions $parserOptions, RevisionRecord $revision, int $options)
 
 shouldUseCache (PageRecord $page, ?RevisionRecord $rev)
 Use a cache? More...
 

Private Attributes

ILBFactory $lbFactory
 
ParserOutput[] $localCache = []
 In cases that an extension tries to get the same ParserOutput of the page right after it was parsed (T301310). More...
 
LoggerSpi $loggerSpi
 
ParserCache $primaryCache
 
RevisionLookup $revisionLookup
 
RevisionRenderer $revisionRenderer
 
RevisionOutputCache $secondaryCache
 
IBufferingStatsdDataFactory $statsDataFactory
 
TitleFormatter $titleFormatter
 
WikiPageFactory $wikiPageFactory
 

Detailed Description

Service for getting rendered output of a given page.

This is a high level service, encapsulating concerns like caching and stampede protection via PoolCounter.

Since
1.36

Definition at line 50 of file ParserOutputAccess.php.

Constructor & Destructor Documentation

◆ __construct()

Page\ParserOutputAccess::__construct ( ParserCache  $primaryCache,
RevisionOutputCache  $secondaryCache,
RevisionLookup  $revisionLookup,
RevisionRenderer  $revisionRenderer,
IBufferingStatsdDataFactory  $statsDataFactory,
ILBFactory  $lbFactory,
LoggerSpi  $loggerSpi,
WikiPageFactory  $wikiPageFactory,
TitleFormatter  $titleFormatter 
)

Member Function Documentation

◆ checkPreconditions()

Page\ParserOutputAccess::checkPreconditions ( PageRecord  $page,
?RevisionRecord  $revision = null,
int  $options = 0 
)
private
Parameters
PageRecord$page
RevisionRecord | null$revision
int$options
Returns
Status|null

Definition at line 326 of file ParserOutputAccess.php.

References StatusValue\newFatal().

◆ getCachedParserOutput()

Page\ParserOutputAccess::getCachedParserOutput ( PageRecord  $page,
ParserOptions  $parserOptions,
?RevisionRecord  $revision = null,
int  $options = 0 
)

Returns the rendered output for the given page if it is present in the cache.

Parameters
PageRecord$page
ParserOptions$parserOptions
RevisionRecord | null$revision
int$optionsBitfield using the OPT_XXX constants
Returns
ParserOutput|null

Definition at line 205 of file ParserOutputAccess.php.

◆ getParserOutput()

Page\ParserOutputAccess::getParserOutput ( PageRecord  $page,
ParserOptions  $parserOptions,
?RevisionRecord  $revision = null,
int  $options = 0 
)

Returns the rendered output for the given page.

Caching and concurrency control is applied.

Parameters
PageRecord$page
ParserOptions$parserOptions
RevisionRecord | null$revision
int$optionsBitfield using the OPT_XXX constants
Returns
Status containing a ParserOutput if no error occurred. Well known errors and warnings include the following messages:
  • 'view-pool-dirty-output' (warning) The output is dirty (from a stale cache entry).
  • 'view-pool-contention' (warning) Dirty output was returned immediately instead of waiting to acquire a work lock (when "fast stale" mode is enabled in PoolCounter).
  • 'view-pool-timeout' (warning) Dirty output was returned after failing to acquire a work lock (got QUEUE_FULL or TIMEOUT from PoolCounter).
  • 'pool-queuefull' (error) unable to acquire work lock, and no cached content found.
  • 'pool-timeout' (error) unable to acquire work lock, and no cached content found.
  • 'pool-servererror' (error) PoolCounterWork failed due to a lock service error.
  • 'pool-unknownerror' (error) PoolCounterWork failed for an unknown reason.
  • 'nopagetext' (error) The page does not exist

Definition at line 261 of file ParserOutputAccess.php.

◆ newPoolWorkArticleView()

Page\ParserOutputAccess::newPoolWorkArticleView ( PageRecord  $page,
ParserOptions  $parserOptions,
RevisionRecord  $revision,
int  $options 
)
private
Parameters
PageRecord$page
ParserOptions$parserOptions
RevisionRecord$revision
int$options
Returns
PoolCounterWork

Definition at line 371 of file ParserOutputAccess.php.

◆ shouldUseCache()

Page\ParserOutputAccess::shouldUseCache ( PageRecord  $page,
?RevisionRecord  $rev 
)
private

Use a cache?

Parameters
PageRecord$page
RevisionRecord | null$rev
Returns
string One of the CACHE_XXX constants.

Definition at line 164 of file ParserOutputAccess.php.

References CACHE_NONE, MediaWiki\Revision\RevisionRecord\DELETED_TEXT, Page\PageIdentity\exists(), MediaWiki\Revision\RevisionRecord\FOR_PUBLIC, and Page\PageRecord\getLatest().

Member Data Documentation

◆ $lbFactory

ILBFactory Page\ParserOutputAccess::$lbFactory
private

Definition at line 112 of file ParserOutputAccess.php.

Referenced by Page\ParserOutputAccess\__construct().

◆ $localCache

ParserOutput [] Page\ParserOutputAccess::$localCache = []
private

In cases that an extension tries to get the same ParserOutput of the page right after it was parsed (T301310).

Definition at line 100 of file ParserOutputAccess.php.

◆ $loggerSpi

LoggerSpi Page\ParserOutputAccess::$loggerSpi
private

Definition at line 115 of file ParserOutputAccess.php.

Referenced by Page\ParserOutputAccess\__construct().

◆ $primaryCache

ParserCache Page\ParserOutputAccess::$primaryCache
private
Initial value:
=
private const CACHE_SECONDARY 'secondary'

Definition at line 88 of file ParserOutputAccess.php.

Referenced by Page\ParserOutputAccess\__construct().

◆ $revisionLookup

RevisionLookup Page\ParserOutputAccess::$revisionLookup
private

Definition at line 103 of file ParserOutputAccess.php.

Referenced by Page\ParserOutputAccess\__construct().

◆ $revisionRenderer

RevisionRenderer Page\ParserOutputAccess::$revisionRenderer
private

Definition at line 106 of file ParserOutputAccess.php.

Referenced by Page\ParserOutputAccess\__construct().

◆ $secondaryCache

RevisionOutputCache Page\ParserOutputAccess::$secondaryCache
private

Definition at line 93 of file ParserOutputAccess.php.

Referenced by Page\ParserOutputAccess\__construct().

◆ $statsDataFactory

IBufferingStatsdDataFactory Page\ParserOutputAccess::$statsDataFactory
private

Definition at line 109 of file ParserOutputAccess.php.

Referenced by Page\ParserOutputAccess\__construct().

◆ $titleFormatter

TitleFormatter Page\ParserOutputAccess::$titleFormatter
private

Definition at line 121 of file ParserOutputAccess.php.

Referenced by Page\ParserOutputAccess\__construct().

◆ $wikiPageFactory

WikiPageFactory Page\ParserOutputAccess::$wikiPageFactory
private

Definition at line 118 of file ParserOutputAccess.php.

Referenced by Page\ParserOutputAccess\__construct().


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