36 private LoggerInterface $logger;
40 private ParsoidSiteConfig $parsoidSiteConfig;
54 ParsoidSiteConfig $parsoidSiteConfig
56 parent::__construct(
'parsoidCachePrewarm',
$params );
59 $this->logger = LoggerFactory::getInstance(
'ParsoidCachePrewarmJob' );
60 $this->parserOutputAccess = $parserOutputAccess;
61 $this->pageLookup = $pageLookup;
62 $this->revisionLookup = $revisionLookup;
63 $this->parsoidSiteConfig = $parsoidSiteConfig;
82 $pageId = $page->getId();
87 $params += self::newRootJobParams(
88 "parsoidCachePrewarm:$pageId:$revisionId:$pageTouched:{$params['options']}"
91 $opts = [
'removeDuplicates' => true ];
94 'parsoidCachePrewarm',
96 'revId' => $revisionId,
98 'page_touched' => $pageTouched,
104 private function doParsoidCacheUpdate() {
105 $page = $this->pageLookup->getPageById( $this->params[
'pageId'] );
106 $revId = $this->params[
'revId'];
108 if ( $page ===
null ) {
110 $this->logger->info(
"Page with ID {$this->params['pageId']} not found" );
116 'ParsoidCachePrewarmJob: The ID of the new revision does not match the page\'s current revision ID'
121 $rev = $this->revisionLookup->getRevisionById( $revId );
127 $parserOpts->setUseParsoid();
129 $renderReason = $this->params[
'causeAction'] ?? $this->command;
130 $parserOpts->setRenderReason( $renderReason );
132 $mainSlot = $rev->getSlot( SlotRecord::MAIN );
133 if ( !$this->parsoidSiteConfig->supportsContentModel( $mainSlot->getModel() ) ) {
134 $this->logger->debug( __METHOD__ .
': Parsoid does not support content model ' . $mainSlot->getModel() );
138 $this->logger->debug( __METHOD__ .
': generating Parsoid output' );
141 $options = $this->params[
'options'] ?? 0;
144 $status = $this->parserOutputAccess->getParserOutput(
151 if ( !$status->isOK() ) {
152 $this->logger->error( __METHOD__ .
': Parsoid error', [
153 'errors' => $status->getErrors(),
155 'rev' => $rev->getId(),
161 $this->doParsoidCacheUpdate();