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