aboutsummaryrefslogtreecommitdiffstats
path: root/tests/phpunit/includes/content/WikitextContentHandlerTest.php
diff options
context:
space:
mode:
authorBrian Wolff <bawolff+wn@gmail.com>2022-04-21 22:47:40 -0700
committerLucas Werkmeister <lucas.werkmeister@wikimedia.de>2022-05-03 11:23:08 +0200
commitbec8dada48e5ba1ffa0345b29f4341e9733af0da (patch)
treeade47965f0f82a8083b8dc5d68ff7b6b8a55def9 /tests/phpunit/includes/content/WikitextContentHandlerTest.php
parentbc6bb2ed6b5f58b2e4881bb76315c52e53aa70ad (diff)
downloadmediawikicore-bec8dada48e5ba1ffa0345b29f4341e9733af0da.tar.gz
mediawikicore-bec8dada48e5ba1ffa0345b29f4341e9733af0da.zip
Clarify generate-html and make ParserOutput behave as expected
Previously: * It was unclear that generate-html is an optional optimization * Most of MediaWiki core was doing $parserOutput->setText('') if html wasn't generated. However this is wrong and will cause $parserOutput->hasText() to return true and also potentially cause cache pollution if a content handler both does that and supports parser cache (Like MassMessage; see T299896) * The default value of mText in the constructor was '', and most of the time MW used that default. This doesn't seem right. If setText() is never called, the ParserOutput should not be considered to have text * It was impossible to set mText to null, as $parserOutput->setText(null) was a no-op. Docs implied you were supposed to do this, so it was very confusing. This patch clarifies docs, changes the default value for ParserOutput::$mText from '' to null, and makes $parserOutput->setText(null) do what you expect it to. The last two are arguably breaking changes, although the previous behaviours were unexpected, mostly undocumented and based on a code search do not appear to be relied on. It seems like the main reason this only broke MassMessage is most content handlers either don't support generateHtml, or they don't support parser cache. Bug: T306591 Change-Id: I49cdf21411c6b02ac9a221a13393bebe17c7871e Depends-On: I68ad491735b2df13951399312a4f9c37b63a08fa
Diffstat (limited to 'tests/phpunit/includes/content/WikitextContentHandlerTest.php')
-rw-r--r--tests/phpunit/includes/content/WikitextContentHandlerTest.php2
1 files changed, 1 insertions, 1 deletions
diff --git a/tests/phpunit/includes/content/WikitextContentHandlerTest.php b/tests/phpunit/includes/content/WikitextContentHandlerTest.php
index 515b2c80639b..e5456753b15d 100644
--- a/tests/phpunit/includes/content/WikitextContentHandlerTest.php
+++ b/tests/phpunit/includes/content/WikitextContentHandlerTest.php
@@ -288,7 +288,7 @@ class WikitextContentHandlerTest extends MediaWikiLangTestCase {
->method( 'getDataForSearchIndex' )
->willReturn( [ 'file_text' => 'This is file content' ] );
- $data = $handler->getDataForSearchIndex( $page, new ParserOutput(), $mockEngine );
+ $data = $handler->getDataForSearchIndex( $page, new ParserOutput( '' ), $mockEngine );
$this->assertArrayHasKey( 'file_text', $data );
$this->assertEquals( 'This is file content', $data['file_text'] );
}