MediaWiki 1.44.0
PoolWorkArticleViewOld.php
Go to the documentation of this file.
1<?php
21namespace MediaWiki\PoolCounter;
22
23use MediaWiki\Logger\Spi as LoggerSpi;
32
40 private $cache;
41
50 public function __construct(
51 PoolCounter $poolCounter,
55 RevisionRenderer $revisionRenderer,
56 LoggerSpi $loggerSpi
57 ) {
58 parent::__construct(
59 $poolCounter,
62 $revisionRenderer,
64 );
65
66 $this->cache = $cache;
67
68 $this->cacheable = true;
69 }
70
74 public function doWork() {
75 // T371713: Temporary statistics collection code to determine
76 // feasibility of Parsoid selective update
77 $sampleRate = MediaWikiServices::getInstance()->getMainConfig()->get(
79 );
80 $doSample = ( $sampleRate && mt_rand( 1, $sampleRate ) === 1 );
81
82 // Reduce effects of race conditions for slow parses (T48014)
83 $cacheTime = wfTimestampNow();
84
85 $status = $this->renderRevision(
86 null, /* don't attempt Parsoid selective updates on this path */
87 $doSample, 'PoolWorkArticleViewOld'
88 );
90 $output = $status->getValue();
91
92 if ( $output && $output->isCacheable() ) {
93 $this->cache->save( $output, $this->revision, $this->parserOptions, $cacheTime );
94 }
95
96 return $status;
97 }
98
102 public function getCachedWork() {
103 $parserOutput = $this->cache->get( $this->revision, $this->parserOptions );
104
105 return $parserOutput ? Status::newGood( $parserOutput ) : false;
106 }
107
108}
109
111class_alias( PoolWorkArticleViewOld::class, 'PoolWorkArticleViewOld' );
wfTimestampNow()
Convenience function; returns MediaWiki timestamp for the present time.
A class containing constants representing the names of configuration variables.
const ParsoidSelectiveUpdateSampleRate
Name constant for the ParsoidSelectiveUpdateSampleRate setting, for use with Config::get()
Service locator for MediaWiki core services.
static getInstance()
Returns the global default instance of the top level service locator.
Set options of the Parser.
ParserOutput is a rendering of a Content object or a message.
Cache for ParserOutput objects.
Semaphore semantics to restrict how many workers may concurrently perform a task.
PoolWorkArticleView for an old revision of a page, using a simple cache.
__construct(PoolCounter $poolCounter, RevisionOutputCache $cache, RevisionRecord $revision, ParserOptions $parserOptions, RevisionRenderer $revisionRenderer, LoggerSpi $loggerSpi)
PoolCounter protected work wrapping RenderedRevision->getRevisionParserOutput.
renderRevision(?ParserOutput $previousOutput=null, bool $doSample=false, string $sourceLabel='')
Render the given revision.
Page revision base class.
The RevisionRenderer service provides access to rendered output for revisions.
Generic operation result class Has warning/error list, boolean status and arbitrary value.
Definition Status.php:54
Service provider interface to create \Psr\Log\LoggerInterface objects.
Definition Spi.php:64