36use Psr\Log\LoggerInterface;
56 $this->logger = $logger;
57 $this->previousParseStackTraces =
new MapCacheLRU( 10 );
70 $pageKey = CacheKeyHelper::getKeyForPage( $page );
74 Title::newFromPageReference( $page )
79 $contentSha1 = $contentStr ? sha1( $contentStr ) :
'INVALID';
81 $index = $this->getParseId( $pageKey, $revId, $optionsHash, $contentSha1 );
83 $stackTrace = (
new RuntimeException() )->getTraceAsString();
84 if ( $this->previousParseStackTraces->has( $index ) ) {
90 __METHOD__ .
': Possibly redundant parse!',
94 'options-hash' => $optionsHash,
95 'contentSha1' => $contentSha1,
96 'trace' => $stackTrace,
97 'previous-trace' => $this->previousParseStackTraces->get( $index ),
101 $this->previousParseStackTraces->set( $index, $stackTrace );
111 private function getParseId(
string $titleStr, ?
int $revId,
string $optionsHash,
string $contentSha1 ): string {
113 $revIdStr = $revId ??
"";
115 return "$titleStr.$revIdStr.$optionsHash.$contentSha1";
Store key-value entries in a size-limited in-memory LRU cache.
Base interface for representing page content.
serialize( $format=null)
Convenience method for serializing this Content object.
isValid()
Returns whether the content is valid.