Debian Codegraph @

includes/page/ParserOutputAccess.php

raw symbols SCIP
1 <?php
2 /**
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * http://www.gnu.org/copyleft/gpl.html
17 *
18 * @file
19 */
20 namespace MediaWiki\Page;
21
22 use InvalidArgumentException;
23 use MapCacheLRU;
24 use MediaWiki\Logger\Spi as LoggerSpi;
25 use MediaWiki\MainConfigNames;
26 use MediaWiki\MediaWikiServices;
27 use MediaWiki\Parser\ParserCache;
28 use MediaWiki\Parser\ParserCacheFactory;
29 use MediaWiki\Parser\ParserOptions;
30 use MediaWiki\Parser\ParserOutput;
31 use MediaWiki\Parser\Parsoid\PageBundleParserOutputConverter;
32 use MediaWiki\Parser\RevisionOutputCache;
33 use MediaWiki\PoolCounter\PoolCounterWork;
34 use MediaWiki\PoolCounter\PoolWorkArticleView;
35 use MediaWiki\PoolCounter\PoolWorkArticleViewCurrent;
36 use MediaWiki\PoolCounter\PoolWorkArticleViewOld;
37 use MediaWiki\Revision\RevisionLookup;
38 use MediaWiki\Revision\RevisionRecord;
39 use MediaWiki\Revision\RevisionRenderer;
40 use MediaWiki\Revision\SlotRecord;
41 use MediaWiki\Status\Status;
42 use MediaWiki\Title\TitleFormatter;
43 use MediaWiki\WikiMap\WikiMap;
44 use Wikimedia\Assert\Assert;
45 use Wikimedia\Parsoid\Parsoid;
46 use Wikimedia\Rdbms\ChronologyProtector;
47 use Wikimedia\Rdbms\ILBFactory;
48 use Wikimedia\Stats\StatsFactory;
49
50 /**
51 * Service for getting rendered output of a given page.
52 *
53 * This is a high level service, encapsulating concerns like caching
54 * and stampede protection via PoolCounter.
55 *
56 * @since 1.36
57 * @ingroup Page
58 */
59 class ParserOutputAccess {
60
61 /** @internal */
62 public const PARSOID_PCACHE_NAME = 'parsoid-' . ParserCacheFactory::DEFAULT_NAME;
63
64 /** @internal */
65 public const PARSOID_RCACHE_NAME = 'parsoid-' . ParserCacheFactory::DEFAULT_RCACHE_NAME;
66
67 /**
68 * @var int Do not check the cache before parsing (force parse)
69 */
70 public const OPT_NO_CHECK_CACHE = 1;
71
72 /** @var int Alias for NO_CHECK_CACHE */
73 public const OPT_FORCE_PARSE = self::OPT_NO_CHECK_CACHE;
74
75 /**
76 * @var int Do not update the cache after parsing.
77 */
78 public const OPT_NO_UPDATE_CACHE = 2;
79
80 /**
81 * @var int Bypass audience check for deleted/suppressed revisions.
82 * The caller is responsible for ensuring that unauthorized access is prevented.
83 * If not set, output generation will fail if the revision is not public.
84 */
85 public const OPT_NO_AUDIENCE_CHECK = 4;
86
87 /**
88 * @var int Do not check the cache before parsing,
89 * and do not update the cache after parsing (not cacheable).
90 */
91 public const OPT_NO_CACHE = self::OPT_NO_UPDATE_CACHE | self::OPT_NO_CHECK_CACHE;
92
93 /**
94 * @var int Do perform an opportunistic LinksUpdate on cache miss
95 * @since 1.41
96 */
97 public const OPT_LINKS_UPDATE = 8;
98
99 /**
100 * Apply page view semantics. This relaxes some guarantees, specifically:
101 * - Use PoolCounter for stampede protection, causing the request to
102 * block until another process has finished rendering the content.
103 * - Allow stale parser output to be returned to prevent long waits for
104 * slow renders.
105 * - Allow cacheable placeholder output to be returned when PoolCounter
106 * fails to obtain a lock. See the PoolCounterConf setting for details.
107 *
108 * @see Bug T352837
109 * @since 1.42
110 */
111 public const OPT_FOR_ARTICLE_VIEW = 16;
112
113 /**
114 * @var int Ignore the profile version of the result from the cache.
115 * Otherwise, if it's not Parsoid's default, it will be invalidated.
116 */
117 public const OPT_IGNORE_PROFILE_VERSION = 128;
118
119 /** @var string Do not read or write any cache */
120 private const CACHE_NONE = 'none';
121
122 /** @var string Use primary cache */
123 private const CACHE_PRIMARY = 'primary';
124
125 /** @var string Use secondary cache */
126 private const CACHE_SECONDARY = 'secondary';
127
128 /**
129 * In cases that an extension tries to get the same ParserOutput of
130 * the page right after it was parsed (T301310).
131 * @var MapCacheLRU<string,ParserOutput>
132 */
133 private MapCacheLRU $localCache;
134
135 private ParserCacheFactory $parserCacheFactory;
136 private RevisionLookup $revisionLookup;
137 private RevisionRenderer $revisionRenderer;
138 private StatsFactory $statsFactory;
139 private ILBFactory $lbFactory;
140 private ChronologyProtector $chronologyProtector;
141 private LoggerSpi $loggerSpi;
142 private WikiPageFactory $wikiPageFactory;
143 private TitleFormatter $titleFormatter;
144
145 public function __construct(
146 ParserCacheFactory $parserCacheFactory,
147 RevisionLookup $revisionLookup,
148 RevisionRenderer $revisionRenderer,
149 StatsFactory $statsFactory,
150 ILBFactory $lbFactory,
151 ChronologyProtector $chronologyProtector,
152 LoggerSpi $loggerSpi,
153 WikiPageFactory $wikiPageFactory,
154 TitleFormatter $titleFormatter
155 ) {
156 $this->parserCacheFactory = $parserCacheFactory;
157 $this->revisionLookup = $revisionLookup;
158 $this->revisionRenderer = $revisionRenderer;
159 $this->statsFactory = $statsFactory;
160 $this->lbFactory = $lbFactory;
161 $this->chronologyProtector = $chronologyProtector;
162 $this->loggerSpi = $loggerSpi;
163 $this->wikiPageFactory = $wikiPageFactory;
164 $this->titleFormatter = $titleFormatter;
165
166 $this->localCache = new MapCacheLRU( 10 );
167 }
168
169 /**
170 * Use a cache?
171 *
172 * @param PageRecord $page
173 * @param RevisionRecord|null $rev
174 *
175 * @return string One of the CACHE_XXX constants.
176 */
177 private function shouldUseCache(
178 PageRecord $page,
179 ?RevisionRecord $rev
180 ) {
181 if ( $rev && !$rev->getId() ) {
182 // The revision isn't from the database, so the output can't safely be cached.
183 return self::CACHE_NONE;
184 }
185
186 // NOTE: Keep in sync with ParserWikiPage::shouldCheckParserCache().
187 // NOTE: when we allow caching of old revisions in the future,
188 // we must not allow caching of deleted revisions.
189
190 $wikiPage = $this->wikiPageFactory->newFromTitle( $page );
191 if ( !$page->exists() || !$wikiPage->getContentHandler()->isParserCacheSupported() ) {
192 return self::CACHE_NONE;
193 }
194
195 $isOld = $rev && $rev->getId() !== $page->getLatest();
196 if ( !$isOld ) {
197 return self::CACHE_PRIMARY;
198 }
199
200 if ( !$rev->audienceCan( RevisionRecord::DELETED_TEXT, RevisionRecord::FOR_PUBLIC ) ) {
201 // deleted/suppressed revision
202 return self::CACHE_NONE;
203 }
204
205 return self::CACHE_SECONDARY;
206 }
207
208 /**
209 * Returns the rendered output for the given page if it is present in the cache.
210 *
211 * @param PageRecord $page
212 * @param ParserOptions $parserOptions
213 * @param RevisionRecord|null $revision
214 * @param int $options Bitfield using the OPT_XXX constants
215 *
216 * @return ParserOutput|null
217 */
218 public function getCachedParserOutput(
219 PageRecord $page,
220 ParserOptions $parserOptions,
221 ?RevisionRecord $revision = null,
222 int $options = 0
223 ): ?ParserOutput {
224 $isOld = $revision && $revision->getId() !== $page->getLatest();
225 $useCache = $this->shouldUseCache( $page, $revision );
226 $primaryCache = $this->getPrimaryCache( $parserOptions );
227 $classCacheKey = $primaryCache->makeParserOutputKey( $page, $parserOptions );
228
229 if ( $useCache === self::CACHE_PRIMARY ) {
230 if ( $this->localCache->hasField( $classCacheKey, $page->getLatest() ) && !$isOld ) {
231 return $this->localCache->getField( $classCacheKey, $page->getLatest() );
232 }
233 $output = $primaryCache->get( $page, $parserOptions );
234 } elseif ( $useCache === self::CACHE_SECONDARY && $revision ) {
235 $secondaryCache = $this->getSecondaryCache( $parserOptions );
236 $output = $secondaryCache->get( $revision, $parserOptions );
237 } else {
238 $output = null;
239 }
240
241 $notHitReason = 'miss';
242 if (
243 $output && !( $options & self::OPT_IGNORE_PROFILE_VERSION ) &&
244 $parserOptions->getUseParsoid()
245 ) {
246 $pageBundleData = $output->getExtensionData(
247 PageBundleParserOutputConverter::PARSOID_PAGE_BUNDLE_KEY
248 );
249 // T333606: Force a reparse if the version coming from cache is not the default
250 $cachedVersion = $pageBundleData['version'] ?? null;
251 if (
252 $cachedVersion !== null && // T325137: BadContentModel, no sense in reparsing
253 $cachedVersion !== Parsoid::defaultHTMLVersion()
254 ) {
255 $notHitReason = 'obsolete';
256 $output = null;
257 }
258 }
259
260 if ( $output && !$isOld ) {
261 $this->localCache->setField( $classCacheKey, $page->getLatest(), $output );
262 }
263
264 if ( $output ) {
265 $this->statsFactory
266 ->getCounter( 'parseroutputaccess_cache' )
267 ->setLabel( 'cache', $useCache )
268 ->setLabel( 'reason', 'hit' )
269 ->setLabel( 'type', 'hit' )
270 ->copyToStatsdAt( "ParserOutputAccess.Cache.$useCache.hit" )
271 ->increment();
272 } else {
273 $this->statsFactory
274 ->getCounter( 'parseroutputaccess_cache' )
275 ->setLabel( 'reason', $notHitReason )
276 ->setLabel( 'cache', $useCache )
277 ->setLabel( 'type', 'miss' )
278 ->copyToStatsdAt( "ParserOutputAccess.Cache.$useCache.$notHitReason" )
279 ->increment();
280 }
281
282 return $output ?: null; // convert false to null
283 }
284
285 /**
286 * Returns the rendered output for the given page.
287 * Caching and concurrency control is applied.
288 *
289 * @param PageRecord $page
290 * @param ParserOptions $parserOptions
291 * @param RevisionRecord|null $revision
292 * @param int $options Bitfield using the OPT_XXX constants
293 *
294 * @return Status containing a ParserOutput if no error occurred.
295 * Well known errors and warnings include the following messages:
296 * - 'view-pool-dirty-output' (warning) The output is dirty (from a stale cache entry).
297 * - 'view-pool-contention' (warning) Dirty output was returned immediately instead of
298 * waiting to acquire a work lock (when "fast stale" mode is enabled in PoolCounter).
299 * - 'view-pool-timeout' (warning) Dirty output was returned after failing to acquire
300 * a work lock (got QUEUE_FULL or TIMEOUT from PoolCounter).
301 * - 'pool-queuefull' (error) unable to acquire work lock, and no cached content found.
302 * - 'pool-timeout' (error) unable to acquire work lock, and no cached content found.
303 * - 'pool-servererror' (error) PoolCounterWork failed due to a lock service error.
304 * - 'pool-unknownerror' (error) PoolCounterWork failed for an unknown reason.
305 * - 'nopagetext' (error) The page does not exist
306 */
307 public function getParserOutput(
308 PageRecord $page,
309 ParserOptions $parserOptions,
310 ?RevisionRecord $revision = null,
311 int $options = 0
312 ): Status {
313 $error = $this->checkPreconditions( $page, $revision, $options );
314 if ( $error ) {
315 $this->statsFactory
316 ->getCounter( 'parseroutputaccess_case' )
317 ->setLabel( 'case', 'error' )
318 ->copyToStatsdAt( 'ParserOutputAccess.Case.error' )
319 ->increment();
320 return $error;
321 }
322
323 $isOld = $revision && $revision->getId() !== $page->getLatest();
324 if ( $isOld ) {
325 $this->statsFactory
326 ->getCounter( 'parseroutputaccess_case' )
327 ->setLabel( 'case', 'old' )
328 ->copyToStatsdAt( 'ParserOutputAccess.Case.old' )
329 ->increment();
330 } else {
331 $this->statsFactory
332 ->getCounter( 'parseroutputaccess_case' )
333 ->setLabel( 'case', 'current' )
334 ->copyToStatsdAt( 'ParserOutputAccess.Case.current' )
335 ->increment();
336 }
337
338 if ( !( $options & self::OPT_NO_CHECK_CACHE ) ) {
339 $output = $this->getCachedParserOutput( $page, $parserOptions, $revision );
340 if ( $output ) {
341 return Status::newGood( $output );
342 }
343 }
344
345 if ( !$revision ) {
346 $revId = $page->getLatest();
347 $revision = $revId ? $this->revisionLookup->getRevisionById( $revId ) : null;
348
349 if ( !$revision ) {
350 $this->statsFactory
351 ->getCounter( 'parseroutputaccess_status' )
352 ->setLabel( 'status', 'norev' )
353 ->copyToStatsdAt( "ParserOutputAccess.Status.norev" )
354 ->increment();
355 return Status::newFatal( 'missing-revision', $revId );
356 }
357 }
358
359 if ( $options & self::OPT_FOR_ARTICLE_VIEW ) {
360 $work = $this->newPoolWorkArticleView( $page, $parserOptions, $revision, $options );
361 /** @var Status $status */
362 $status = $work->execute();
363 } else {
364 // XXX: we could try harder to reuse a cache lookup above to
365 // provide the $previous argument here
366 $status = $this->renderRevision( $page, $parserOptions, $revision, $options, null );
367 }
368
369 $output = $status->getValue();
370 Assert::postcondition( $output || !$status->isOK(), 'Inconsistent status' );
371
372 if ( $output && !$isOld ) {
373 $primaryCache = $this->getPrimaryCache( $parserOptions );
374 $classCacheKey = $primaryCache->makeParserOutputKey( $page, $parserOptions );
375 $this->localCache->setField( $classCacheKey, $page->getLatest(), $output );
376 }
377
378 if ( $status->isGood() ) {
379 $this->statsFactory->getCounter( 'parseroutputaccess_status' )
380 ->setLabel( 'status', 'good' )
381 ->copyToStatsdAt( 'ParserOutputAccess.Status.good' )
382 ->increment();
383 } elseif ( $status->isOK() ) {
384 $this->statsFactory->getCounter( 'parseroutputaccess_status' )
385 ->setLabel( 'status', 'ok' )
386 ->copyToStatsdAt( 'ParserOutputAccess.Status.ok' )
387 ->increment();
388 } else {
389 $this->statsFactory->getCounter( 'parseroutputaccess_status' )
390 ->setLabel( 'status', 'error' )
391 ->copyToStatsdAt( 'ParserOutputAccess.Status.error' )
392 ->increment();
393 }
394
395 return $status;
396 }
397
398 /**
399 * Render the given revision.
400 *
401 * This method will update the parser cache if appropriate, and will
402 * trigger a links update if OPT_LINKS_UPDATE is set.
403 *
404 * This method does not perform access checks, and will not load content
405 * from caches. The caller is assumed to have taken care of that.
406 *
407 * Where possible, pass in a $previousOutput, which will prevent an
408 * unnecessary double-lookup in the cache.
409 *
410 * @see PoolWorkArticleView::renderRevision
411 */
412 private function renderRevision(
413 PageRecord $page,
414 ParserOptions $parserOptions,
415 RevisionRecord $revision,
416 int $options,
417 ?ParserOutput $previousOutput = null
418 ): Status {
419 $this->statsFactory->getCounter( 'parseroutputaccess_poolwork' )
420 ->copyToStatsdAt( 'ParserOutputAccess.PoolWork.None' )
421 ->setLabel( 'cache', self::CACHE_NONE )
422 ->increment();
423
424 $useCache = $this->shouldUseCache( $page, $revision );
425
426 // T371713: Temporary statistics collection code to determine
427 // feasibility of Parsoid selective update
428 $sampleRate = MediaWikiServices::getInstance()->getMainConfig()->get(
429 MainConfigNames::ParsoidSelectiveUpdateSampleRate
430 );
431 $doSample = ( $sampleRate && mt_rand( 1, $sampleRate ) === 1 );
432
433 if ( $previousOutput === null && ( $doSample || $parserOptions->getUseParsoid() ) ) {
434 // If $useCache === self::CACHE_SECONDARY we could potentially
435 // try to reuse the parse of $revision-1 from the secondary cache,
436 // but it is likely those template transclusions are out of date.
437 // Try to reuse the template transclusions from the most recent
438 // parse, which are more likely to reflect the current template.
439 if ( !( $options & self::OPT_NO_CHECK_CACHE ) ) {
440 $previousOutput = $this->getPrimaryCache( $parserOptions )->getDirty( $page, $parserOptions ) ?: null;
441 }
442 }
443
444 $renderedRev = $this->revisionRenderer->getRenderedRevision(
445 $revision,
446 $parserOptions,
447 null,
448 [
449 'audience' => RevisionRecord::RAW,
450 'previous-output' => $previousOutput,
451 ]
452 );
453
454 $output = $renderedRev->getRevisionParserOutput();
455
456 if ( $doSample ) {
457 $content = $revision->getContent( SlotRecord::MAIN );
458 $labels = [
459 'source' => 'ParserOutputAccess',
460 'type' => $previousOutput === null ? 'full' : 'selective',
461 'reason' => $parserOptions->getRenderReason(),
462 'parser' => $parserOptions->getUseParsoid() ? 'parsoid' : 'legacy',
463 'opportunistic' => 'false',
464 'wiki' => WikiMap::getCurrentWikiId(),
465 'model' => $content ? $content->getModel() : 'unknown',
466 ];
467 $this->statsFactory
468 ->getCounter( 'ParserCache_selective_total' )
469 ->setLabels( $labels )
470 ->increment();
471 $this->statsFactory
472 ->getCounter( 'ParserCache_selective_cpu_seconds' )
473 ->setLabels( $labels )
474 ->incrementBy( $output->getTimeProfile( 'cpu' ) );
475 }
476
477 if ( !( $options & self::OPT_NO_UPDATE_CACHE ) && $output->isCacheable() ) {
478 if ( $useCache === self::CACHE_PRIMARY ) {
479 $primaryCache = $this->getPrimaryCache( $parserOptions );
480 $primaryCache->save( $output, $page, $parserOptions );
481 } elseif ( $useCache === self::CACHE_SECONDARY ) {
482 $secondaryCache = $this->getSecondaryCache( $parserOptions );
483 $secondaryCache->save( $output, $revision, $parserOptions );
484 }
485 }
486
487 if ( $options & self::OPT_LINKS_UPDATE ) {
488 $this->wikiPageFactory->newFromTitle( $page )
489 ->triggerOpportunisticLinksUpdate( $output );
490 }
491
492 return Status::newGood( $output );
493 }
494
495 /**
496 * @param PageRecord $page
497 * @param RevisionRecord|null $revision
498 * @param int $options
499 *
500 * @return Status|null
501 */
502 private function checkPreconditions(
503 PageRecord $page,
504 ?RevisionRecord $revision = null,
505 int $options = 0
506 ): ?Status {
507 if ( !$page->exists() ) {
508 return Status::newFatal( 'nopagetext' );
509 }
510
511 if ( !( $options & self::OPT_NO_UPDATE_CACHE ) && $revision && !$revision->getId() ) {
512 throw new InvalidArgumentException(
513 'The revision does not have a known ID. Use OPT_NO_CACHE.'
514 );
515 }
516
517 if ( $revision && $revision->getPageId() !== $page->getId() ) {
518 throw new InvalidArgumentException(
519 'The revision does not belong to the given page.'
520 );
521 }
522
523 if ( $revision && !( $options & self::OPT_NO_AUDIENCE_CHECK ) ) {
524 // NOTE: If per-user checks are desired, the caller should perform them and
525 // then set OPT_NO_AUDIENCE_CHECK if they passed.
526 if ( !$revision->audienceCan( RevisionRecord::DELETED_TEXT, RevisionRecord::FOR_PUBLIC ) ) {
527 return Status::newFatal(
528 'missing-revision-permission',
529 $revision->getId(),
530 $revision->getTimestamp(),
531 $this->titleFormatter->getPrefixedDBkey( $page )
532 );
533 }
534 }
535
536 return null;
537 }
538
539 /**
540 * @param PageRecord $page
541 * @param ParserOptions $parserOptions
542 * @param RevisionRecord $revision
543 * @param int $options
544 *
545 * @return PoolCounterWork
546 */
547 protected function newPoolWorkArticleView(
548 PageRecord $page,
549 ParserOptions $parserOptions,
550 RevisionRecord $revision,
551 int $options
552 ): PoolCounterWork {
553 $useCache = $this->shouldUseCache( $page, $revision );
554
555 switch ( $useCache ) {
556 case self::CACHE_PRIMARY:
557 $this->statsFactory->getCounter( 'parseroutputaccess_poolwork' )
558 ->setLabel( 'cache', self::CACHE_PRIMARY )
559 ->copyToStatsdAt( 'ParserOutputAccess.PoolWork.Current' )
560 ->increment();
561 $primaryCache = $this->getPrimaryCache( $parserOptions );
562 $parserCacheMetadata = $primaryCache->getMetadata( $page );
563 $cacheKey = $primaryCache->makeParserOutputKey( $page, $parserOptions,
564 $parserCacheMetadata ? $parserCacheMetadata->getUsedOptions() : null
565 );
566
567 $workKey = $cacheKey . ':revid:' . $revision->getId();
568
569 return new PoolWorkArticleViewCurrent(
570 $workKey,
571 $page,
572 $revision,
573 $parserOptions,
574 $this->revisionRenderer,
575 $primaryCache,
576 $this->lbFactory,
577 $this->chronologyProtector,
578 $this->loggerSpi,
579 $this->wikiPageFactory,
580 !( $options & self::OPT_NO_UPDATE_CACHE ),
581 (bool)( $options & self::OPT_LINKS_UPDATE )
582 );
583
584 case self::CACHE_SECONDARY:
585 $this->statsFactory->getCounter( 'parseroutputaccess_poolwork' )
586 ->setLabel( 'cache', self::CACHE_SECONDARY )
587 ->copyToStatsdAt( 'ParserOutputAccess.PoolWork.Old' )
588 ->increment();
589 $secondaryCache = $this->getSecondaryCache( $parserOptions );
590 $workKey = $secondaryCache->makeParserOutputKey( $revision, $parserOptions );
591 return new PoolWorkArticleViewOld(
592 $workKey,
593 $secondaryCache,
594 $revision,
595 $parserOptions,
596 $this->revisionRenderer,
597 $this->loggerSpi
598 );
599
600 default:
601 $this->statsFactory->getCounter( 'parseroutputaccess_poolwork' )
602 ->setLabel( 'cache', self::CACHE_NONE )
603 ->copyToStatsdAt( 'ParserOutputAccess.PoolWork.Uncached' )
604 ->increment();
605 $secondaryCache = $this->getSecondaryCache( $parserOptions );
606 $workKey = $secondaryCache->makeParserOutputKeyOptionalRevId( $revision, $parserOptions );
607 return new PoolWorkArticleView(
608 $workKey,
609 $revision,
610 $parserOptions,
611 $this->revisionRenderer,
612 $this->loggerSpi
613 );
614 }
615
616 // unreachable
617 }
618
619 private function getPrimaryCache( ParserOptions $pOpts ): ParserCache {
620 if ( $pOpts->getUseParsoid() ) {
621 return $this->parserCacheFactory->getParserCache(
622 self::PARSOID_PCACHE_NAME
623 );
624 }
625
626 return $this->parserCacheFactory->getParserCache(
627 ParserCacheFactory::DEFAULT_NAME
628 );
629 }
630
631 private function getSecondaryCache( ParserOptions $pOpts ): RevisionOutputCache {
632 if ( $pOpts->getUseParsoid() ) {
633 return $this->parserCacheFactory->getRevisionOutputCache(
634 self::PARSOID_RCACHE_NAME
635 );
636 }
637
638 return $this->parserCacheFactory->getRevisionOutputCache(
639 ParserCacheFactory::DEFAULT_RCACHE_NAME
640 );
641 }
642
643 }