MediaWiki REL1_39
PoolWorkArticleViewOld.php
Go to the documentation of this file.
1<?php
21use MediaWiki\Logger\Spi as LoggerSpi;
25
32
34 private $cache;
35
44 public function __construct(
45 string $workKey,
47 RevisionRecord $revision,
48 ParserOptions $parserOptions,
49 RevisionRenderer $revisionRenderer,
50 LoggerSpi $loggerSpi
51 ) {
52 parent::__construct( $workKey, $revision, $parserOptions, $revisionRenderer, $loggerSpi );
53
54 $this->cache = $cache;
55
56 $this->cacheable = true;
57 }
58
62 public function doWork() {
63 // Reduce effects of race conditions for slow parses (T48014)
64 $cacheTime = wfTimestampNow();
65
66 $status = $this->renderRevision();
68 $output = $status->getValue();
69
70 if ( $output && $output->isCacheable() ) {
71 $this->cache->save( $output, $this->revision, $this->parserOptions, $cacheTime );
72 }
73
74 return $status;
75 }
76
80 public function getCachedWork() {
81 $parserOutput = $this->cache->get( $this->revision, $this->parserOptions );
82
83 return $parserOutput ? Status::newGood( $parserOutput ) : false;
84 }
85
86}
wfTimestampNow()
Convenience function; returns MediaWiki timestamp for the present time.
Cache for ParserOutput objects.
Page revision base class.
The RevisionRenderer service provides access to rendered output for revisions.
Set options of the Parser.
PoolWorkArticleView for an old revision of a page, using a simple cache.
__construct(string $workKey, RevisionOutputCache $cache, RevisionRecord $revision, ParserOptions $parserOptions, RevisionRenderer $revisionRenderer, LoggerSpi $loggerSpi)
PoolCounter protected work wrapping RenderedRevision->getRevisionParserOutput.
Service provider interface for \Psr\Log\LoggerInterface implementation libraries.
Definition Spi.php:38
$cache
Definition mcc.php:33