36use Psr\Log\LoggerInterface;
53 $this->logger = $logger;
54 $this->previousParseStackTraces =
new MapCacheLRU( 10 );
67 $pageKey = CacheKeyHelper::getKeyForPage( $page );
71 Title::newFromPageReference( $page )
76 $contentSha1 = $contentStr ? sha1( $contentStr ) :
'INVALID';
78 $index = $this->getParseId( $pageKey, $revId, $optionsHash, $contentSha1 );
80 $stackTrace = (
new RuntimeException() )->getTraceAsString();
81 if ( $this->previousParseStackTraces->has( $index ) ) {
87 __METHOD__ .
': Possibly redundant parse!',
91 'options-hash' => $optionsHash,
92 'contentSha1' => $contentSha1,
93 'trace' => $stackTrace,
94 'previous-trace' => $this->previousParseStackTraces->get( $index ),
98 $this->previousParseStackTraces->set( $index, $stackTrace );
108 private function getParseId(
string $titleStr, ?
int $revId,
string $optionsHash,
string $contentSha1 ): string {
110 $revIdStr = $revId ??
"";
112 return "$titleStr.$revIdStr.$optionsHash.$contentSha1";
Store key-value entries in a size-limited in-memory LRU cache.
Content objects represent page content, e.g.
serialize( $format=null)
Serialize this Content object.
isValid()
Whether the content is valid.