MediaWiki master
ParserCacheFilter.php
Go to the documentation of this file.
1<?php
8namespace MediaWiki\Parser;
9
11
21
25 private array $config;
26
30 public function __construct( array $config ) {
31 $this->config = $config;
32 }
33
34 public function shouldCache(
35 ParserOutput $output,
36 PageRecord $page,
37 ParserOptions $options
38 ): bool {
39 $ns = $page->getNamespace();
40 $cpuMin = $this->config[ $ns ]['minCpuTime']
41 ?? ( $this->config['default']['minCpuTime'] ?? 0 );
42
43 $cpuTime = $output->getTimeProfile( 'cpu' );
44
45 if ( $cpuTime !== null && $cpuTime < $cpuMin ) {
46 return false;
47 }
48
49 return true;
50 }
51
52}
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.