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;
117 $keyPrefix = $this->cacheKey ?: ObjectCache::getLocalClusterInstance()->makeKey(
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 );
202 $logger = MediaWiki\Logger\LoggerFactory::getInstance(
'slow-parse' );
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;
268 $this->
error = $status;
$wgUseFileCache
This will cache static pages for non-logged-in users to reduce database traffic on public sites.
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
wfTimestampNow()
Convenience function; returns MediaWiki timestamp for the present time.
wfDebugLog( $logGroup, $text, $dest='all', array $context=[])
Send a line to a supplementary debug log file, if configured, or main debug log if not.
Set options of the Parser.
Class for dealing with PoolCounters using class members.
RevisionStore $revisionStore
RevisionRenderer $renderer
getError()
Get a Status object in case of error or false otherwise.
ParserOutput bool $parserOutput
ParserOptions $parserOptions
getParserOutput()
Get the ParserOutput from this object, or false in case of failure.
getIsDirty()
Get whether the ParserOutput is a dirty one (i.e.
RevisionRecord null $revision
__construct(WikiPage $page, ParserOptions $parserOptions, $revid, $useParserCache, $revision=null, $audience=RevisionRecord::FOR_PUBLIC)
Generic operation result class Has warning/error list, boolean status and arbitrary value.
Class representing a MediaWiki article and history.
getRevision()
Get the latest revision.
getTitle()
Get the title object of the article.
Base interface for content objects.