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, ParserOptions $parserOptions, ?RevisionRecord $rev)
 Use a cache? More...
 

Private Attributes

ILBFactory $lbFactory
 
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
Stability: unstable
Extensions should use WikiPage::getParserOutput until this class has settled down.

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

◆ 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 201 of file ParserOutputAccess.php.

References Page\ParserOutputAccess\shouldUseCache().

Referenced by Page\ParserOutputAccess\getParserOutput().

◆ 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 is 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 245 of file ParserOutputAccess.php.

References Page\ParserOutputAccess\checkPreconditions(), Page\ParserOutputAccess\getCachedParserOutput(), Page\PageRecord\getLatest(), StatusValue\newFatal(), StatusValue\newGood(), and Page\ParserOutputAccess\newPoolWorkArticleView().

◆ newPoolWorkArticleView()

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

Definition at line 370 of file ParserOutputAccess.php.

References CACHE_NONE, and Page\ParserOutputAccess\shouldUseCache().

Referenced by Page\ParserOutputAccess\getParserOutput().

◆ shouldUseCache()

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

Use a cache?

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

Definition at line 159 of file ParserOutputAccess.php.

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

Referenced by Page\ParserOutputAccess\getCachedParserOutput(), and Page\ParserOutputAccess\newPoolWorkArticleView().

Member Data Documentation

◆ $lbFactory

ILBFactory Page\ParserOutputAccess::$lbFactory
private

Definition at line 106 of file ParserOutputAccess.php.

Referenced by Page\ParserOutputAccess\__construct().

◆ $loggerSpi

LoggerSpi Page\ParserOutputAccess::$loggerSpi
private

Definition at line 109 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 89 of file ParserOutputAccess.php.

Referenced by Page\ParserOutputAccess\__construct().

◆ $revisionLookup

RevisionLookup Page\ParserOutputAccess::$revisionLookup
private

Definition at line 97 of file ParserOutputAccess.php.

Referenced by Page\ParserOutputAccess\__construct().

◆ $revisionRenderer

RevisionRenderer Page\ParserOutputAccess::$revisionRenderer
private

Definition at line 100 of file ParserOutputAccess.php.

Referenced by Page\ParserOutputAccess\__construct().

◆ $secondaryCache

RevisionOutputCache Page\ParserOutputAccess::$secondaryCache
private

Definition at line 94 of file ParserOutputAccess.php.

Referenced by Page\ParserOutputAccess\__construct().

◆ $statsDataFactory

IBufferingStatsdDataFactory Page\ParserOutputAccess::$statsDataFactory
private

Definition at line 103 of file ParserOutputAccess.php.

Referenced by Page\ParserOutputAccess\__construct().

◆ $titleFormatter

TitleFormatter Page\ParserOutputAccess::$titleFormatter
private

Definition at line 115 of file ParserOutputAccess.php.

Referenced by Page\ParserOutputAccess\__construct().

◆ $wikiPageFactory

WikiPageFactory Page\ParserOutputAccess::$wikiPageFactory
private

Definition at line 112 of file ParserOutputAccess.php.

Referenced by Page\ParserOutputAccess\__construct().


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