From 45305de579f6805a7387c2c72082e8febc870350 Mon Sep 17 00:00:00 2001 From: "C. Scott Ananian" Date: Tue, 25 Sep 2018 10:05:55 -0400 Subject: [PATCH] Hard deprecate non-tidy OutputPage::addWikiText() method Tidy will always be enabled with our future parsers. Hard-deprecate this method which doesn't tidy the output. Users of `OutputPage::addWikiText()` will be converted one-by-one to `OutputPage::addWikiTextAsInterface()` so that any unexpected issues (deliberately untidy wikitext added, which should be rare) can be addressed. Bug: T198214 Depends-On: I778ba9e6efed576605f492c9a073c7203b6c0477 Depends-On: I16529879a3b3aed960c5dc006e2af513d7e91fcd Change-Id: If8353c37245d9d233d589f82c198668ccb3fce05 --- includes/OutputPage.php | 5 +++++ tests/phpunit/includes/OutputPageTest.php | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/includes/OutputPage.php b/includes/OutputPage.php index 3a0a529ee9..32f46b17f0 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -1758,6 +1758,7 @@ class OutputPage extends ContextSource { * or else addWikiTextAsContent() if $interface is false. */ public function addWikiText( $text, $linestart = true, $interface = true ) { + wfDeprecated( __METHOD__, '1.32' ); $title = $this->getTitle(); if ( !$title ) { throw new MWException( 'Title is null' ); @@ -1936,6 +1937,10 @@ class OutputPage extends ContextSource { ) { global $wgParser; + if ( !$tidy ) { + wfDeprecated( 'disabling tidy', '1.32' ); + } + $popts = $this->parserOptions(); $oldTidy = $popts->setTidy( $tidy ); $popts->setInterfaceMessage( (bool)$interface ); diff --git a/tests/phpunit/includes/OutputPageTest.php b/tests/phpunit/includes/OutputPageTest.php index 18d2a8a671..ba9a94ebd8 100644 --- a/tests/phpunit/includes/OutputPageTest.php +++ b/tests/phpunit/includes/OutputPageTest.php @@ -1442,10 +1442,13 @@ class OutputPageTest extends MediaWikiTestCase { $op = $this->newInstance(); $this->assertSame( '', $op->getHTML() ); + $this->hideDeprecated( 'OutputPage::addWikiText' ); $this->hideDeprecated( 'OutputPage::addWikiTextTitle' ); $this->hideDeprecated( 'OutputPage::addWikiTextWithTitle' ); $this->hideDeprecated( 'OutputPage::addWikiTextTidy' ); $this->hideDeprecated( 'OutputPage::addWikiTextTitleTidy' ); + $this->hideDeprecated( 'disabling tidy' ); + if ( in_array( $method, [ 'addWikiTextWithTitle', 'addWikiTextTitleTidy', 'addWikiTextTitle' ] @@ -1614,6 +1617,7 @@ class OutputPageTest extends MediaWikiTestCase { * @covers OutputPage::addWikiText */ public function testAddWikiTextNoTitle() { + $this->hideDeprecated( 'OutputPage::addWikiText' ); $this->setExpectedException( MWException::class, 'Title is null' ); $op = $this->newInstance( [], null, 'notitle' ); -- 2.20.1