Since I72c5e6f86b7f081ab5ce7a56f5365d2f75067a78 it is part of the contract of ContentRenderer::getParserOutput() that the render ID (and other cache parameters) will be set when it returns. (ContentHandler::getParserOutput() can set them even earlier if it has custom content-based overrides.) We had a lot of temporary backward-compatibility code "later" in the parse process to try to close the barn door if some code path "forgot" to set them, but these are unnecessary now. This patch removes that backward-compatibility code in ParsoidParser; there is similar remaining code in ParserCache etc. which can be addressed in follow ups. (For compatibility we do have to temporarily copy the render ID code inside ParsoidOutputAccess::parseUncachable, but that class is deprecated and will be removed.) The HtmlOutputRendererHelper path which used to call ParsoidParser::parseFakeRevision() is now replaced with a codepath that goes through RevisionRenderer. In order to maintain the same behavior of the ParsoidHandler, we have also added 'useParsoid' handling to the JsonContentHandler. This support can perhaps be deprecated eventually. Bug: T350538 Change-Id: I0853624cf785f72fd956c6c2336f979f4402a68f
67 lines
1.9 KiB
PHP
67 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace MediaWiki\Parser\Parsoid;
|
|
|
|
use MediaWiki\Languages\LanguageConverterFactory;
|
|
use MediaWiki\Parser\Parsoid\Config\PageConfigFactory;
|
|
use ParserFactory;
|
|
use Wikimedia\Parsoid\Config\DataAccess;
|
|
use Wikimedia\Parsoid\Config\SiteConfig;
|
|
use Wikimedia\Parsoid\Parsoid;
|
|
|
|
/**
|
|
* ParserFactory which uses a ParsoidParser.
|
|
*
|
|
* This is similar to \ParserFactory, but simplified since we don't need
|
|
* to try to reuse parser objects. Eventually we'll be able to simplify
|
|
* \ParserFactory the same way.
|
|
*
|
|
* @since 1.41
|
|
* @internal May be combined with \ParserFactory or otherwise refactored
|
|
*
|
|
* @file
|
|
* @ingroup Parser
|
|
*/
|
|
class ParsoidParserFactory /* eventually this may extend \ParserFactory */ {
|
|
private SiteConfig $siteConfig;
|
|
private DataAccess $dataAccess;
|
|
private PageConfigFactory $pageConfigFactory;
|
|
private LanguageConverterFactory $languageConverterFactory;
|
|
private ParserFactory $legacyParserFactory;
|
|
|
|
/**
|
|
* @param SiteConfig $siteConfig
|
|
* @param DataAccess $dataAccess
|
|
* @param PageConfigFactory $pageConfigFactory
|
|
* @param LanguageConverterFactory $languageConverterFactory
|
|
* @param ParserFactory $legacyParserFactory
|
|
*/
|
|
public function __construct(
|
|
SiteConfig $siteConfig,
|
|
DataAccess $dataAccess,
|
|
PageConfigFactory $pageConfigFactory,
|
|
LanguageConverterFactory $languageConverterFactory,
|
|
ParserFactory $legacyParserFactory
|
|
) {
|
|
$this->siteConfig = $siteConfig;
|
|
$this->dataAccess = $dataAccess;
|
|
$this->pageConfigFactory = $pageConfigFactory;
|
|
$this->languageConverterFactory = $languageConverterFactory;
|
|
$this->legacyParserFactory = $legacyParserFactory;
|
|
}
|
|
|
|
/**
|
|
* Creates a new Parsoid parser.
|
|
* @return ParsoidParser
|
|
* @since 1.41
|
|
* @unstable
|
|
*/
|
|
public function create(): ParsoidParser {
|
|
return new ParsoidParser(
|
|
new Parsoid( $this->siteConfig, $this->dataAccess ),
|
|
$this->pageConfigFactory,
|
|
$this->languageConverterFactory,
|
|
$this->legacyParserFactory
|
|
);
|
|
}
|
|
}
|