Disable Parsoid support for non-default output versions and offset types

* This is in service of a followup patch that merges ParsoidOutputAccess
  and ParserOutputAccess. We want to eliminate all Parsoid-specific options
  that aren't part of ParserOptions and aren't easily supportable via
  html2html transforms.

* offsetType conversion relies on Parsoid code that is a bit entangled
  with env, siteconfig (and extension configs), page source, etc. It
  could all be refactored but once the html2html output transformation
  framework lands, we could potentially use that to call Parsoid to do
  these transforms by exposing such transforms to the framework.

* In this patch, outputContentVersion that isn't the default major HTML
  version is no longer support. It could potentially be supported via the
  downgrade functionality in Parsoid in the future, or we might decide
  to re-enable multiple outputContentVersion selection in the future
  if such a use case arises. But, there are no plans to bump the major
  HTML version in the near future while we work on read views.

* Rather than delete associated tests, I've marked them skipped so that
  they can re-enabled when this support is added back.

Bug: T347426
Change-Id: Ibede4acd68e944512f6d00763d29c6b1605d67eb
This commit is contained in:
Subramanya Sastry 2023-09-14 15:44:20 -05:00
parent 62bb717fe3
commit 1aa71cf51b
4 changed files with 26 additions and 9 deletions

View file

@ -228,9 +228,15 @@ class HtmlOutputRendererHelper implements HtmlOutputHelper {
// Only set the option if the value isn't the default!
if ( $outputContentVersion !== Parsoid::defaultHTMLVersion() ) {
// See Parsoid::wikitext2html
$this->parsoidOptions['outputContentVersion'] = $outputContentVersion;
$this->isCacheable = false;
throw new HttpException( "Unsupported profile version: $version", 406 );
// TODO: (T347426) At some later point, we may reintroduce support for
// non-default content versions as part of work on the content
// negotiatiation protocol.
//
// // See Parsoid::wikitext2html
// $this->parsoidOptions['outputContentVersion'] = $outputContentVersion;
// $this->isCacheable = false;
}
}
@ -245,8 +251,15 @@ class HtmlOutputRendererHelper implements HtmlOutputHelper {
// Only set the option if the value isn't the default (see Wikimedia\Parsoid\Config\Env)!
// See Parsoid::wikitext2html for possible values.
if ( $offsetType !== 'byte' ) {
$this->parsoidOptions['offsetType'] = $offsetType;
$this->isCacheable = false;
// (T347426) If there is a real use case for this, we might support
// this. But, it requires us to be able to run a Parsoid htm2html
// transform on the output doc. The current transformation in
// Parsoid\ContentUtils has dependencies on Parsoid env, Siteconfig
// and page source which makes it not possible to be run directly.
throw new HttpException( "Unsupported offset type: $offsetType", 406 );
// $this->parsoidOptions['offsetType'] = $offsetType;
// $this->isCacheable = false;
}
}

View file

@ -266,7 +266,8 @@ describe( '/transform/ endpoint', function () {
.end( done );
} );
it( 'should prefer higher quality (html)', function ( done ) {
// T347426: Support for non-default major HTML versions has been disabled
it.skip( 'should prefer higher quality (html)', function ( done ) {
const contentVersion = '999.0.0';
client.req
.post( endpointPrefix + '/transform/wikitext/to/html/' )
@ -383,7 +384,8 @@ describe( '/transform/ endpoint', function () {
.end( done );
} );
it( 'should accept requests for content version 999.x (html)', function ( done ) {
// T347426: Support for non-default major HTML versions has been disabled
it.skip( 'should accept requests for content version 999.x (html)', function ( done ) {
const contentVersion = '999.0.0';
client.req
.post( endpointPrefix + '/transform/wikitext/to/html/' )

View file

@ -358,6 +358,7 @@ class HtmlOutputRendererHelperTest extends MediaWikiIntegrationTestCase {
}
public function testGetPageBundleWithOptions() {
$this->markTestSkipped( 'T347426: Support for non-default output content major version + offset type has been disabled.' );
$page = $this->getExistingTestPage( __METHOD__ );
$helper = $this->newHelper();

View file

@ -1896,7 +1896,7 @@ class ParsoidHandlerTest extends MediaWikiIntegrationTestCase {
'mwAQ' => [],
'mwAg' => [ 'dsr' => [ 0, 22, 0, 0 ] ],
],
'offsetType' => 'ucs2', // as provided in the input
'offsetType' => 'byte', // as provided in the input
]
],
];
@ -1907,7 +1907,8 @@ class ParsoidHandlerTest extends MediaWikiIntegrationTestCase {
'oldid' => 1, // will be replaced by a real revision id
'opts' => [ 'format' => ParsoidFormatHelper::FORMAT_PAGEBUNDLE ],
'envOptions' => [
'offsetType' => 'ucs2', // make sure this is looped through to data-parsoid attribute
// Used to test 'ucs2' before, but we dropped that support here
'offsetType' => 'byte', // make sure this is looped through to data-parsoid attribute
]
];
yield 'should get from a title and revision (pagebundle)' => [