37 use Psr\Log\LoggerInterface;
54 private $previousParseStackTraces;
60 $this->logger = $logger;
61 $this->previousParseStackTraces = [];
83 $contentSha1 = $contentStr ? sha1( $contentStr ) :
'INVALID';
85 $index = $this->getParseId( $pageKey, $revId, $optionsHash, $contentSha1 );
87 $stackTrace = (
new RuntimeException() )->getTraceAsString();
88 if ( array_key_exists( $index, $this->previousParseStackTraces ) ) {
94 __METHOD__ .
': Possibly redundant parse!',
98 'options-hash' => $optionsHash,
99 'contentSha1' => $contentSha1,
100 'trace' => $stackTrace,
101 'previous-trace' => $this->previousParseStackTraces[$index],
105 $this->previousParseStackTraces[$index] = $stackTrace;
115 private function getParseId(
string $titleStr, ?
int $revId,
string $optionsHash,
string $contentSha1 ): string {
117 $revIdStr = $revId ??
"";
119 return "$titleStr.$revIdStr.$optionsHash.$contentSha1";
getUsedOptions()
Returns the options from its ParserOptions which have been taken into account to produce the output.
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.