MediaWiki master
ParserCacheFilter.php
Go to the documentation of this file.
1<?php
22namespace MediaWiki\Parser;
23
26
36
40 private array $config;
41
45 public function __construct( array $config ) {
46 $this->config = $config;
47 }
48
49 public function shouldCache(
50 ParserOutput $output,
51 PageRecord $page,
52 ParserOptions $options
53 ): bool {
54 $ns = $page->getNamespace();
55 $cpuMin = $this->config[ $ns ]['minCpuTime']
56 ?? ( $this->config['default']['minCpuTime'] ?? 0 );
57
58 $cpuTime = $output->getTimeProfile( 'cpu' );
59
60 if ( $cpuTime !== null && $cpuTime < $cpuMin ) {
61 return false;
62 }
63
64 return true;
65 }
66
67}
shouldCache(ParserOutput $output, PageRecord $page, ParserOptions $options)
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...
Set options of the Parser.
Data record representing a page that is (or used to be, or could be) an editable page on a wiki.