From 96292e770a2e5a2f7fb578ff101111f081dafb68 Mon Sep 17 00:00:00 2001 From: daniel Date: Thu, 6 Apr 2023 12:17:11 +0200 Subject: [PATCH] Don't force the "view" flavor when using stashing! Bug: T333402 Change-Id: I6fc598cb2309c442a0b5bfe665f6f96c1a6edf85 --- includes/DirectParsoidClient.php | 4 +++- tests/phpunit/integration/DirectParsoidClientTest.php | 5 +++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/includes/DirectParsoidClient.php b/includes/DirectParsoidClient.php index 5a4bdaad99..2ccf97f68d 100644 --- a/includes/DirectParsoidClient.php +++ b/includes/DirectParsoidClient.php @@ -85,7 +85,9 @@ class DirectParsoidClient implements ParsoidClient { $helper->init( $page, [], $user, $revision ); $helper->setStashingEnabled( $stash ); - $helper->setFlavor( $flavor ); + if ( !$stash ) { + $helper->setFlavor( $flavor ); + } if ( $revision ) { $helper->setRevision( $revision ); diff --git a/tests/phpunit/integration/DirectParsoidClientTest.php b/tests/phpunit/integration/DirectParsoidClientTest.php index 831869c12e..1bfb374d6d 100644 --- a/tests/phpunit/integration/DirectParsoidClientTest.php +++ b/tests/phpunit/integration/DirectParsoidClientTest.php @@ -195,6 +195,11 @@ class DirectParsoidClientTest extends MediaWikiIntegrationTestCase { $oldHtml = $pageHtmlResponse['body']; $updatedHtml = str_replace( '', '

More Text

', $oldHtml ); + // Make sure the etag is for "stash" flavor HTML. + // The ETag should be transparent, but this is the easiest way to check that we are getting + // the correct flavor of HTML. + $this->assertMatchesRegularExpression( '@/stash\b@', $eTag ); + // Now make a new client object, so we can mock the ParsoidOutputAccess. $parsoidOutputAccess = $this->createNoOpMock( ParsoidOutputAccess::class ); $services = $this->getServiceContainer();