MediaWiki master
MediaWiki\Page\ParserOutputAccess Class Reference

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

Inherits LoggerAwareInterface.

Collaboration diagram for MediaWiki\Page\ParserOutputAccess:

Public Member Functions

 __construct (ParserCacheFactory $parserCacheFactory, RevisionLookup $revisionLookup, RevisionRenderer $revisionRenderer, StatsFactory $statsFactory, ChronologyProtector $chronologyProtector, WikiPageFactory $wikiPageFactory, TitleFormatter $titleFormatter, TracerInterface $tracer, PoolCounterFactory $poolCounterFactory)
 
 clearLocalCache ()
 Clear the local cache.
 
 getCachedParserOutput (PageRecord $page, ParserOptions $parserOptions, ?RevisionRecord $revision=null, $options=[])
 Get the rendered output for the given page if it is present in the cache.
 
 getParserOutput (PageRecord $page, ParserOptions $parserOptions, ?RevisionRecord $revision=null, $options=[])
 Returns the rendered output for the given page.
 
 postprocess (ParserOutput $output, ParserOptions $parserOptions)
 Postprocess the given ParserOutput.
 
 setLogger (LoggerInterface $logger)
 

Public Attributes

const OPT_FOR_ARTICLE_VIEW = 16
 Apply page view semantics.
 
const OPT_POOL_COUNTER = 'poolcounter-type'
 
const OPT_POOL_COUNTER_FALLBACK = 'poolcounter-fallback'
 Whether to fall back to using stale content when failing to get a poolcounter lock.
 
const PARSOID_PCACHE_NAME = 'parsoid-' . ParserCacheFactory::DEFAULT_NAME
 
const PARSOID_RCACHE_NAME = 'parsoid-' . ParserCacheFactory::DEFAULT_RCACHE_NAME
 
const POOL_COUNTER_ARTICLE_VIEW = 'ArticleView'
 
const POOL_COUNTER_REST_API = 'HtmlRestApi'
 
const POSTPROC_CACHE_PREFIX = 'postproc-'
 

Protected Member Functions

 newPoolWork (PageRecord $page, ParserOptions $parserOptions, RevisionRecord $revision, array $options)
 

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

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Page\ParserOutputAccess::__construct ( ParserCacheFactory $parserCacheFactory,
RevisionLookup $revisionLookup,
RevisionRenderer $revisionRenderer,
StatsFactory $statsFactory,
ChronologyProtector $chronologyProtector,
WikiPageFactory $wikiPageFactory,
TitleFormatter $titleFormatter,
TracerInterface $tracer,
PoolCounterFactory $poolCounterFactory )

Definition at line 172 of file ParserOutputAccess.php.

Member Function Documentation

◆ clearLocalCache()

MediaWiki\Page\ParserOutputAccess::clearLocalCache ( )

Clear the local cache.

Since
1.45

Definition at line 805 of file ParserOutputAccess.php.

◆ getCachedParserOutput()

MediaWiki\Page\ParserOutputAccess::getCachedParserOutput ( PageRecord $page,
ParserOptions $parserOptions,
?RevisionRecord $revision = null,
$options = [] )

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

Parameters
PageRecord$page
ParserOptions$parserOptions
RevisionRecord | null$revision
int | array$optionsBitfield or associative array using the OPT_XXX constants. Passing an int is deprecated and will trigger deprecation warnings in the future.
Returns
ParserOutput|null

Definition at line 301 of file ParserOutputAccess.php.

◆ getParserOutput()

MediaWiki\Page\ParserOutputAccess::getParserOutput ( PageRecord $page,
ParserOptions $parserOptions,
?RevisionRecord $revision = null,
$options = [] )

Returns the rendered output for the given page.

Caching and concurrency control is applied.

Parameters
PageRecord$page
ParserOptions$parserOptions
RevisionRecord | null$revision
int | array$optionsBitfield or associative array using the OPT_XXX constants. Passing an int is deprecated and will trigger deprecation warnings in the future.
Returns
Status<ParserOutput> 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 436 of file ParserOutputAccess.php.

◆ newPoolWork()

MediaWiki\Page\ParserOutputAccess::newPoolWork ( PageRecord $page,
ParserOptions $parserOptions,
RevisionRecord $revision,
array $options )
protected

Definition at line 670 of file ParserOutputAccess.php.

◆ postprocess()

MediaWiki\Page\ParserOutputAccess::postprocess ( ParserOutput $output,
ParserOptions $parserOptions )

Postprocess the given ParserOutput.

Definition at line 827 of file ParserOutputAccess.php.

References MediaWiki\Parser\ParserOptions\getOption().

◆ setLogger()

MediaWiki\Page\ParserOutputAccess::setLogger ( LoggerInterface $logger)

Definition at line 197 of file ParserOutputAccess.php.

Member Data Documentation

◆ OPT_FOR_ARTICLE_VIEW

const MediaWiki\Page\ParserOutputAccess::OPT_FOR_ARTICLE_VIEW = 16

Apply page view semantics.

This relaxes some guarantees, specifically:

  • Use PoolCounter for stampede protection, causing the request to block until another process has finished rendering the content.
  • Allow stale parser output to be returned to prevent long waits for slow renders.
  • Allow cacheable placeholder output to be returned when PoolCounter fails to obtain a lock. See the PoolCounterConf setting for details.
See also
Bug T352837
Since
1.42
Deprecated
since 1.45, instead use OPT_POOL_COUNTER => POOL_COUNTER_ARTICLE_VIEW and OPT_POOL_COUNTER_FALLBACK => true.

Definition at line 102 of file ParserOutputAccess.php.

◆ OPT_POOL_COUNTER

const MediaWiki\Page\ParserOutputAccess::OPT_POOL_COUNTER = 'poolcounter-type'
See also
MainConfigSchema::PoolCounterConf

Definition at line 124 of file ParserOutputAccess.php.

◆ OPT_POOL_COUNTER_FALLBACK

const MediaWiki\Page\ParserOutputAccess::OPT_POOL_COUNTER_FALLBACK = 'poolcounter-fallback'

Whether to fall back to using stale content when failing to get a poolcounter lock.

Definition at line 119 of file ParserOutputAccess.php.

◆ PARSOID_PCACHE_NAME

const MediaWiki\Page\ParserOutputAccess::PARSOID_PCACHE_NAME = 'parsoid-' . ParserCacheFactory::DEFAULT_NAME
Access: internal

Definition at line 48 of file ParserOutputAccess.php.

◆ PARSOID_RCACHE_NAME

const MediaWiki\Page\ParserOutputAccess::PARSOID_RCACHE_NAME = 'parsoid-' . ParserCacheFactory::DEFAULT_RCACHE_NAME
Access: internal

Definition at line 51 of file ParserOutputAccess.php.

◆ POOL_COUNTER_ARTICLE_VIEW

const MediaWiki\Page\ParserOutputAccess::POOL_COUNTER_ARTICLE_VIEW = 'ArticleView'
See also
MainConfigSchema::PoolCounterConf

Definition at line 129 of file ParserOutputAccess.php.

◆ POOL_COUNTER_REST_API

const MediaWiki\Page\ParserOutputAccess::POOL_COUNTER_REST_API = 'HtmlRestApi'
See also
MainConfigSchema::PoolCounterConf

Definition at line 134 of file ParserOutputAccess.php.

◆ POSTPROC_CACHE_PREFIX

const MediaWiki\Page\ParserOutputAccess::POSTPROC_CACHE_PREFIX = 'postproc-'
Access: internal

Definition at line 54 of file ParserOutputAccess.php.


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