20use Psr\Log\LoggerInterface;
28 private LoggerInterface $logger;
32 private ParsoidSiteConfig $parsoidSiteConfig;
46 ParsoidSiteConfig $parsoidSiteConfig
48 parent::__construct(
'parsoidCachePrewarm',
$params );
51 $this->logger = LoggerFactory::getInstance(
'ParsoidCachePrewarmJob' );
52 $this->parserOutputAccess = $parserOutputAccess;
53 $this->pageLookup = $pageLookup;
54 $this->revisionLookup = $revisionLookup;
55 $this->parsoidSiteConfig = $parsoidSiteConfig;
74 $pageId = $page->getId();
80 "parsoidCachePrewarm:$pageId:$revisionId:$pageTouched:{$params['options']}"
83 $opts = [
'removeDuplicates' => true ];
86 'parsoidCachePrewarm',
88 'revId' => $revisionId,
90 'page_touched' => $pageTouched,
98 private function doParsoidCacheUpdate() {
99 $page = $this->pageLookup->getPageById( $this->params[
'pageId'] );
100 $revId = $this->params[
'revId'];
102 if ( $page ===
null ) {
104 $this->logger->info(
"Page with ID {$this->params['pageId']} not found" );
108 RequestContext::getMain()->setTitle( $this->title );
112 'ParsoidCachePrewarmJob: The ID of the new revision does not match the page\'s current revision ID'
117 $rev = $this->revisionLookup->getRevisionById( $revId );
122 $parserOpts = ParserOptions::newFromAnon();
123 $parserOpts->setUseParsoid();
125 $renderReason = $this->params[
'causeAction'] ?? $this->command;
126 $parserOpts->setRenderReason( $renderReason );
128 $mainSlot = $rev->getSlot( SlotRecord::MAIN );
129 if ( !$this->parsoidSiteConfig->supportsContentModel( $mainSlot->getModel() ) ) {
130 $this->logger->debug( __METHOD__ .
': Parsoid does not support content model ' . $mainSlot->getModel() );
134 $this->logger->debug( __METHOD__ .
': generating Parsoid output' );
137 $options = $this->params[
'options'] ?? 0;
140 $status = $this->parserOutputAccess->getParserOutput(
147 if ( !$status->isOK() ) {
148 $this->logger->error( __METHOD__ .
': Parsoid error', [
149 'errors' => $status->getErrors(),
151 'rev' => $rev->getId(),
158 $this->doParsoidCacheUpdate();
165class_alias( ParsoidCachePrewarmJob::class,
'ParsoidCachePrewarmJob' );
Group all the pieces relevant to the context of a request into one instance.
Service for getting rendered output of a given page.
Service for looking up information about wiki pages.
getDBkey()
Get the page title in DB key form.