MediaWiki master
ParserCacheFilter.php
Go to the documentation of this file.
1<?php
8namespace MediaWiki\Parser;
9
11
20
24 private array $config;
25
29 public function __construct( array $config ) {
30 $this->config = $config;
31 }
32
33 public function shouldCache(
34 ParserOutput $output,
35 PageRecord $page,
36 ParserOptions $options
37 ): bool {
38 $ns = $page->getNamespace();
39 $cpuMin = $this->config[ $ns ]['minCpuTime']
40 ?? ( $this->config['default']['minCpuTime'] ?? 0 );
41
42 $cpuTime = $output->getTimeProfile( 'cpu' );
43
44 if ( $cpuTime !== null && $cpuTime < $cpuMin ) {
45 return false;
46 }
47
48 return true;
49 }
50
51}
Filter that decides whether a ParserOutput object should be stored in the ParserCache or not.
shouldCache(ParserOutput $output, PageRecord $page, ParserOptions $options)
Set options of the Parser.
ParserOutput is a rendering of a Content object or a message.
getTimeProfile(string $clock)
Returns the time that elapsed between the most recent call to resetParseStartTime() and the first cal...
Data record representing a page that is (or used to be, or could be) an editable page on a wiki.