37use Psr\Log\LoggerInterface;
57 $this->logger = $logger;
58 $this->previousParseStackTraces =
new MapCacheLRU( 10 );
71 $pageKey = CacheKeyHelper::getKeyForPage( $page );
75 Title::newFromPageReference( $page )
80 $contentSha1 = $contentStr ? sha1( $contentStr ) :
'INVALID';
82 $index = $this->getParseId( $pageKey, $revId, $optionsHash, $contentSha1 );
84 $stackTrace = (
new RuntimeException() )->getTraceAsString();
85 if ( $this->previousParseStackTraces->has( $index ) ) {
91 __METHOD__ .
': Possibly redundant parse!',
95 'options-hash' => $optionsHash,
96 'contentSha1' => $contentSha1,
97 'trace' => $stackTrace,
98 'previous-trace' => $this->previousParseStackTraces->get( $index ),
102 $this->previousParseStackTraces->set( $index, $stackTrace );
112 private function getParseId(
string $titleStr, ?
int $revId,
string $optionsHash,
string $contentSha1 ): string {
114 $revIdStr = $revId ??
"";
116 return "$titleStr.$revIdStr.$optionsHash.$contentSha1";
getUsedOptions()
Returns the options from its ParserOptions which have been taken into account to produce the output.
Store key-value entries in a size-limited in-memory LRU cache.
Set options of the Parser.
optionsHash( $forOptions, $title=null)
Generate a hash string with the values set on these ParserOptions for the keys given in the array.
Base interface for representing page content.
serialize( $format=null)
Convenience method for serializing this Content object.
isValid()
Returns whether the content is valid.