From f2b325002b23c1e0bd70d28fd19c27fd1d537e61 Mon Sep 17 00:00:00 2001 From: "C. Scott Ananian" Date: Fri, 21 Sep 2018 13:16:42 -0400 Subject: [PATCH] Hard deprecate unused OutputPage::addWikiText* methods Codesearch shows no users of `OutputPage::addWikiTextWithTitle()`, and no users of `OutputPage::addWikiTextTitle()` (other than the implicit uses by the other `OutputPage::addWikiText*()` methods). These methods produce untidy output, which future parsers won't support. Bug: T198214 Change-Id: Id5ee3bdfa6c464e3a92af82af7bc7317ca9d07a9 --- includes/OutputPage.php | 34 +++++++++++++++++++---- tests/phpunit/includes/OutputPageTest.php | 2 ++ 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/includes/OutputPage.php b/includes/OutputPage.php index 5801a29ac9..f2b343ec0e 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -1757,7 +1757,7 @@ class OutputPage extends ContextSource { if ( !$title ) { throw new MWException( 'Title is null' ); } - $this->addWikiTextTitle( $text, $title, $linestart, /*tidy*/false, $interface ); + $this->addWikiTextTitleInternal( $text, $title, $linestart, /*tidy*/false, $interface ); } /** @@ -1785,7 +1785,7 @@ class OutputPage extends ContextSource { if ( !$title ) { throw new MWException( 'Title is null' ); } - $this->addWikiTextTitle( $text, $title, $linestart, /*tidy*/true, /*interface*/true ); + $this->addWikiTextTitleInternal( $text, $title, $linestart, /*tidy*/true, /*interface*/true ); } /** @@ -1812,7 +1812,7 @@ class OutputPage extends ContextSource { if ( !$title ) { throw new MWException( 'Title is null' ); } - $this->addWikiTextTitle( $text, $title, $linestart, /*tidy*/true, /*interface*/false ); + $this->addWikiTextTitleInternal( $text, $title, $linestart, /*tidy*/true, /*interface*/false ); } /** @@ -1825,7 +1825,8 @@ class OutputPage extends ContextSource { * addWikiTextAsInterface() */ public function addWikiTextWithTitle( $text, Title $title, $linestart = true ) { - $this->addWikiTextTitle( $text, $title, $linestart ); + wfDeprecated( __METHOD__, '1.32' ); + $this->addWikiTextTitleInternal( $text, $title, $linestart, /*tidy*/false, /*interface*/false ); } /** @@ -1839,7 +1840,7 @@ class OutputPage extends ContextSource { * addWikiTextAsContent() */ function addWikiTextTitleTidy( $text, Title $title, $linestart = true ) { - $this->addWikiTextTitle( $text, $title, $linestart, true ); + $this->addWikiTextTitleInternal( $text, $title, $linestart, /*tidy*/true, /*interface*/false ); } /** @@ -1855,7 +1856,7 @@ class OutputPage extends ContextSource { if ( !$title ) { throw new MWException( 'Title is null' ); } - $this->addWikiTextTitleTidy( $text, $title, $linestart ); + $this->addWikiTextTitleInternal( $text, $title, $linestart, /*tidy*/true, /*interface*/false ); } /** @@ -1879,6 +1880,27 @@ class OutputPage extends ContextSource { */ public function addWikiTextTitle( $text, Title $title, $linestart, $tidy = false, $interface = false + ) { + wfDeprecated( __METHOD__, '1.32' ); + return $this->addWikiTextTitleInternal( $text, $title, $linestart, $tidy, $interface ); + } + + /** + * Add wikitext with a custom Title object. + * Output is unwrapped. + * + * @param string $text Wikitext + * @param Title $title + * @param bool $linestart Is this the start of a line? + * @param bool $tidy Whether to use tidy. + * Setting this to false (or omitting it) is deprecated + * since 1.32; all wikitext should be tidied. + * @param bool $interface Whether it is an interface message + * (for example disables conversion) + * @private + */ + private function addWikiTextTitleInternal( + $text, Title $title, $linestart, $tidy, $interface ) { global $wgParser; diff --git a/tests/phpunit/includes/OutputPageTest.php b/tests/phpunit/includes/OutputPageTest.php index f9c293cdec..8a4b5c3f1d 100644 --- a/tests/phpunit/includes/OutputPageTest.php +++ b/tests/phpunit/includes/OutputPageTest.php @@ -1404,6 +1404,8 @@ class OutputPageTest extends MediaWikiTestCase { $op = $this->newInstance(); $this->assertSame( '', $op->getHTML() ); + $this->hideDeprecated( 'OutputPage::addWikiTextTitle' ); + $this->hideDeprecated( 'OutputPage::addWikiTextWithTitle' ); if ( in_array( $method, [ 'addWikiTextWithTitle', 'addWikiTextTitleTidy', 'addWikiTextTitle' ] -- 2.20.1