96 throw new InvalidArgumentException(
'$revid parameter mismatches $revision parameter' );
101 throw new InvalidArgumentException(
'$page parameter mismatches $revision parameter' );
106 $this->renderer = MediaWikiServices::getInstance()->getRevisionRenderer();
107 $this->revisionStore = MediaWikiServices::getInstance()->getRevisionStore();
108 $this->parserCache = MediaWikiServices::getInstance()->getParserCache();
112 $this->cacheable = $useParserCache;
118 'articleview',
'missingcachekey'
121 parent::__construct(
'ArticleView', $keyPrefix .
':revid:' .
$revid );
160 $isCurrent = $this->revid === $this->page->getLatest();
165 if ( $this->revision !==
null ) {
167 } elseif ( $isCurrent ) {
168 $rev = $this->page->getRevision()
169 ? $this->page->getRevision()->getRevisionRecord()
172 $rev = $this->revisionStore->getRevisionByTitle( $this->page->getTitle(),
$this->revid );
180 $renderedRevision = $this->renderer->getRenderedRevision(
182 $this->parserOptions,
187 if ( !$renderedRevision ) {
195 $time = - microtime(
true );
196 $this->parserOutput = $renderedRevision->getRevisionParserOutput();
197 $time += microtime(
true );
203 $logger->info(
'{time} {title}', [
204 'time' => number_format( $time, 2 ),
205 'title' => $this->page->getTitle()->getPrefixedDBkey(),
206 'ns' => $this->page->getTitle()->getNamespace(),
211 if ( $this->cacheable && $this->parserOutput->isCacheable() && $isCurrent ) {
212 $this->parserCache->save(
213 $this->parserOutput, $this->page, $this->parserOptions, $cacheTime, $this->revid );
219 if ( !$this->parserOutput->isCacheable() ) {
224 $this->page->triggerOpportunisticLinksUpdate( $this->parserOutput );
234 $this->parserOutput = $this->parserCache->get( $this->page, $this->parserOptions );
236 if ( $this->parserOutput ===
false ) {
237 wfDebug( __METHOD__ .
": parser cache miss\n" );
240 wfDebug( __METHOD__ .
": parser cache hit\n" );
249 $this->parserOutput = $this->parserCache->getDirty( $this->page, $this->parserOptions );
251 if ( $this->parserOutput ===
false ) {
253 wfDebug( __METHOD__ .
": no dirty cache\n" );
256 wfDebug( __METHOD__ .
": sending dirty output\n" );
257 wfDebugLog(
'dirty',
"dirty output {$this->cacheKey}" );
258 $this->isDirty =
true;